Showing posts with label dialog. Show all posts
Showing posts with label dialog. Show all posts

Monday, March 26, 2012

Modal Popup from Code Behind ?

Is there a way I can use the modal popup extender from the code behind? I'd like it to popup as a "confirm" dialog if a value in the form is within a specific range. ie: if a date is less than three days away.

Thanks !!!

Probably the best way to do this is to place your form controls inside of an update panel. Then based on the items chosen you change the enabled property on the modal popup extender. You could add the control to the Controls set on your page, but depending on your form validation, that may happen too late in the game.

Hope that helps!

Saturday, March 24, 2012

ModalDialog inside updatepanel

I've got a button that shows a modal dialog box. The idea is to add an object to a database, then refresh a listbox on the main page. The dialog works correctly, except with click cmdOk, the server side function is never called. I suspect it's because there's no longer an event handler registered by JS that calls the script to do the postback. I probably need to create a client side script using OnOkScript="onOK()", but I have no idea how to make the page postback to call cmdNewObject_Click without a full postback. Any ideas?

Thanks,

Rick

<asp:LinkButtonID="cmdAddObject"runat="server"Text="Add Object"></asp:LinkButton>

<cc1:ModalPopupExtenderID="ModalPopupExtender1"runat="server">

<cc1:ModalPopupPropertiesBackgroundCssClass="modalBackground"OkControlID="cmdOk"CancelControlID="cmdCancel"DropShadow="true"PopupControlID="pnlAddObject"TargetControlID="cmdAddObject"></cc1:ModalPopupProperties>

</cc1:ModalPopupExtender>

<atlas:UpdatePanelID="pnlPopup"runat="server"Mode="conditional">

<Triggers>

<atlas:ControlEventTriggerControlID="cmdOk"EventName="Click"/>

</Triggers>

<ContentTemplate>

<asp:PanelID="pnlAddObject"runat="server"CssClass="modalPopup"Style="display: none">

<div>

<divid="ObjectName">

<asp:TextBoxID="txtObjectName"runat="server"></asp:TextBox></div>

<div>

<divid="OkButton">

<asp:ButtonID="cmdOk"runat="server"OnClick="cmdNewObject_Click"Text="New Object"/></div>

<divid="CancelButton">

<asp:ButtonID="cmdCancel"runat="server"Text="Cancel"/></div>

</div>

</div>

</asp:Panel>

</ContentTemplate>

</atlas:UpdatePanel>

Seethis post and maybe consider removing the OkControlID property so the Ok button can postback normally (thereby dismissing the ModalPopup). I'm thinking you may also want to get rid of the UpdatePanel here as I'm not sure it'll ultimately be necessary.