Showing posts with label popup. Show all posts
Showing posts with label popup. Show all posts

Monday, March 26, 2012

Trigger full postback from the server during a partial postback.

Well, I have a dialog user control (ajax popup) which can again contain other user asp user controls as content. The content of the dialog is created inside an UpdatePanel, so that the dialog content can postback. All of that works OK.

On the web page I have now some information visible inside a GridView which is not in an UpdatePanel and should not be, because I need the browser forward/backward button to work. A link on that web page lets one of these dialog controls pop up. The dialog contains a user control which can manipulate the data which is visible inside the GridView. If the user presses a button inside the dialog, the dialog does an asynchronous postback as the user control/dialog content is inside an update panel and the dialog closes. That gives the user the impression that nothing happened as the data visible in the GridView did not change. I do already have the code to refresh the gridview, but how can I change the behavior during the postback from being an asynchronous postback to a full postback?

So just to clarify some pseudo code:

In the user control contained inside the dialog I would have some code like:

void OnOK(...)
{
// check if any data changed
if (textBox.Text != record.Text)
{
// do a database update
// and
// update cached data which the datagrid is bound to
// call a method on the page to rebind the datagrid only

// ? Force a full page refresh
}
else
{
// do nothing
// asynchronous postback is OK, no full page refresh needed
}
}

The force of a full page refresh is what I would need. In a fat environment like Windows Forms, I would just call Invalidate on the Form. Or IF the DataGrid would be inside an UpdatePanel I would search for it and call Update() on it, but then I would loose the browser caching during back and forward movements. So I was searching through all of the classes if there is something like ScriptManager.UpdatePage or something similar, but have found nothing so far.

So what is the solution here? How can inform the ajax client side script, that it should just go ahead and rerender the whole page instead of just extracting the update panel portions?

Thanks

In the <Triggers> collection of your updatepanel, just add whatever control you want to cause a full refresh as a PostBackTrigger instead of as a AsynchPostBackTrigger.

<asp:UpdatePanel ...>
<Triggers>
<asp:PostBackTrigger ControlID="whateverID" />
</Triggers>
<ContentTemplate>
...
</ContentTemplate>
</asp:UpdatePanel>


Well, that does not work:

a) the UserControl is designed separatly and does not have an update panel and vice versa the dialog is a generic control which just adds a UserControl as a content, so it cannot hardcode if there is any control ID inside which should trigger a full postback

b) I do not want a full postback to occur all the time when the button is pressed, the logic of the button on the server side should determine if a full postback is necessary or not, if not then a partial postback is OK.


I tried to work around now, kind of using your approach by doing this in the OnPreRender or OnChildControlsCreated of the UserControl:

System.Web.UI.WebControls.WebControl btnOK =this.Parent.Parent.FindControl("btnOK")as System.Web.UI.WebControls.WebControl;
if (btnOK !=null)
{
System.Web.UI.Control control = btnOK;
UpdatePanel updatePanel = control.ParentasUpdatePanel;
while ((updatePanel ==null) && (control !=null))
{
control = control.Parent;
updatePanel = controlasUpdatePanel;
}
if (updatePanel !=null)
{
PostBackTrigger pbTrigger =newPostBackTrigger();
pbTrigger.ControlID ="btnOK";
updatePanel.Triggers.Add(pbTrigger);
}
}

So I do find the OK button and I do find the UpdatePanel that contains the button, but it has no effect whatsoever.
The control ID must be right, otherwise I would not be able to find the button with it, but still no PostBack and the Dialog itself is not inside an UpdatePanel.

Trigger Modal Popup from clientside JavaScript

Hi!

How can I trigger a Modal Popup from client-side JavaScript, without having to have it triggered off of a LinkButton server control?

The modal popup demo on the Sample website shows how to show/hide the popup in script.


Would you believe I must have looked at that page dozens and dozens of times and never noticed that blurb down below?Embarrassed

I must admit that one of the problems is that the documentation on the page makes no reference to the BehaviorID property of the ModalPopupExtender... I only found it through extensive Googling...


That blurb was just added last week after we received more than a couple of requests for demo'ing how to programmatically show/hide modalpopups.

Regarding your question about BehaviorID, it is not ModalPopup specific but something that is part of the Toolkit ExtenderControlBase class so all the extenders in the Toolkit have it. You can find more information on that in theExtender Base Class features walkthrough on the Toolkit sample website.


Aaah! Whew! Now I don't feel so bad :)

And thanks for the pointer on the BehaviorID stuff... I think in my haste to see what the toolkit had to offer I didn't dig deep enough to find out about the extras. Just what I needed!

Saturday, March 24, 2012

trigger updatePanel update on close of modalPopup

i've got a popup prompting for uname & pwd. on close of the popup (and successful auth), i'd like to be able to update the loginView and treeView (menu) on the main page, which are both in updatePanels.

my best solution so far is to have buttons with width & height = 0 in the updatePanels and then do a button.click() call from my modal's onOk() script. this seem kinda unelegant to me, and i'm convinced there has to be a better way.

is there not a way to trigger an updatePanel.update() from (client) script??

thanx...!

Asking this question in one of the non-Toolkit Atlas forums may get you better answers.

Triggering modal popup with javascript causes popup controls to be disabled and popup disa

I'm triggering a modal popup to popup in a javascript:

document.getElementById('ModalPopupTrigger').click();

The element specified is set as the TargetControl for the modal popup.

The popup does popup but the control's on it can't be used and the popup disappears automatically after ~ 2 seconds...

Any clues as to what's going on here?

Define the BehaviorID property of your ModalPopupExtender control and use its show() method. For example (taken from the toolkit sample):

<ajaxToolkit:ModalPopupExtender runat="server" ID="programmaticModalPopup" BehaviorID="programmaticModalPopupBehavior" TargetControlID="hiddenTargetControlForModalPopup" PopupControlID="programmaticPopup"
BackgroundCssClass="modalBackground" DropShadow="True" PopupDragHandleControlID="programmaticPopupDragHandle" >

Given that declaration, you can show the popup by calling $find('programmaticModalPopupBehavior').show()


Ok, both methods actually work. The problem turned out to be that the javascript was triggered by a link button in an update panel which was causing the panel with the popup to refresh. Changed it to a label and it works fine...

Wednesday, March 21, 2012

Trouble getting started with drag/drop -- JS Error

Hi,

I am new to Atlas and am working my way through some tutorials. I am trying to use some hover/popup behaviors that rely on the AtlasUIDragDrop script. However, when I try to load it up I get a JS error. I've got a bunch of other atlas controls on the same page, and they all work, so I'm not sure what's wrong.

Here's what I have:

<atlas:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<atlas:ScriptReference ScriptName="AtlasUIDragDrop" />
</Scripts>
</atlas:ScriptManager>
...
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<references>
<add src="http://pics.10026.com/?src=ScriptLibrary/Atlas/Release/AtlasUIDragDrop.js" />
</references>
<components>
...

When I load up my page, I get the following JS error:

"Web is not defined. AtlasUIDragDrop.js (line 6)"

Thanks in advance for any help!

-Nick
Hi,

check your code because the Web namespace has been renamed to Sys.
Thanks - that did the trick.

Nick

Trouble with Accordion Panel inside a Modal Popup

When I use modal popup to show the tab control and other controls, the modal popup resizes correctly. Granted, the shadow behind does not, but this is avoidable by removing the drop shadow. The problem comes when I try to use an accordion panel inside a modal popup. The accordion panel doesn't respond well to clicks and the modal popup window does not resize to compensate for the dynamic panel. I encased the accordion panel in a regular panel so I could give the modalpopup extender's popupcontrolID something to play with.

I'm sure I'm doing something wrong here, but I cannot figure out what is happening exactly. Anyone experienced anything similar to this or know of a solution? Thanks!Big Smile

Bump?Angel

trying to add a popup/tooltip to an updatepanels gridview item

Hi everyone,

I have a Gridview that I want to place inside an update panel, but the current javascript tooltip calls bomb out. These calls are created dynamically (some results have the popup, others don't) and store text helping to explain the search results. Can someone lead me in the direction of what I need to be doing here or the control needed to make it work?

Try to take a look at the following links about javascript tooltip for reference.
http://www.walterzorn.com/tooltip/tooltip_e.htm#download
http://www.webreference.com/js/column16/
http://www.dustindiaz.com/sweet-titles
http://javascript.internet.com/generators/dhtml-tooltip-generator.html
http://tooltip.crtx.org/
Wish the above can help you.