Showing posts with label trigger. Show all posts
Showing posts with label trigger. Show all posts

Monday, March 26, 2012

Programmatically trigger modal popup

I want to write a page that checks for a cookie via Javascript and then possibly opens a modal dialog box. How do I trigger the modal popup via client side javascript?

I saw the example that comes on the modal dialog that sample page, however that works with a client side event such as a click. Can I do it without listening for an event?

Hi theregit,

In the javascript where you check the cookie, you can trigger a button.

That button's click event can then be another javascript that opens a modal window.

Trigger the button like:
var myButton = document.getElementById('myButton');
myButton.click();

Is this an answer to your question?
if you have comments/remarks/questions .. please do so!

Kind regards
Wim


Try this ,

Show and Hide ModalPopupExtender from JavaScript

Hope this helps


Phanatic,

Thank you sooo much for that post. I was having the problem with the 'null' is null or not an object error. Once I used the pageLoad() method it worked great.

Proper time to add UpdatePanel trigger

What is the proper time to add a trigger to an UpdatePanel from code-behind?

I currently have a control that acts as a NamingContainer. I am trying to have it register a couple of its buttons as async triggers if it senses that it is a child of an UpdatePanel. This is because these controls are databound (there are multiples of them in one UpdatePanel) so I cannot add the IDs of the controls declaratively.

I tried adding them in the PreRender phase of the control, but when I try it out I get a nasty exception on Render during a postback (below). I can only assume (from reflection) that initially, the triggers are being created when the controls are recreated from ViewState, then the controls those triggers reference get tossed aside when the list databinds after the change, so there's a null reference when the triggers from the first set try to find their real controls. However, I don't have any idea how to avoid this. Any help would be greatly appreciated.

Object reference not set to an instance of an object. 0.273490066474929 0.000559
at System.Web.UI.AsyncPostBackTrigger.HasTriggered()
at System.Web.UI.UpdatePanelTriggerCollection.HasTriggered()
at System.Web.UI.UpdatePanel.get_RequiresUpdate()
at System.Web.UI.PageRequestManager.ProcessUpdatePanels()
at System.Web.UI.PageRequestManager.RenderPageCallback(HtmlTextWriter writer, Control pageControl)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at IDM.Manage.UI.Page.Render(HtmlTextWriter writer) in C:\Projects\IDM.Manage\IDM.Manage\UI\Page.cs:line 39

I had this same problem when trying to add a trigger in the Page_Load.

It worked fine when I moved it to the Page_Init