Monday, March 26, 2012

How do I create a popup that has a button that submits to server?

I have this in my page

<div>
<asp:ButtonID="RefreshAreasButton"runat="server"OnClick="RefreshAreasButton_Click"Text="Refresh"/>
<asp:ButtonID="DeleteAreaButton"runat="server"Text="Delete"/>
<!-- Delete popup -->
<asp:PanelID="DeletePanel"runat="server"CssClass="modalPopup"Style="display: none"Height="115px"Width="255px">
<asp:TextBoxID="TextBox1"runat="server"Text="Delete Selected Areas"></asp:TextBox>
<asp:ButtonID="DeleteOKBtn"runat="server"Text="OK"OnClick="DeleteOKBtn_Click"/>
<asp:ButtonID="DeleteCancelBtn"runat="server"Text="Cancel"/>
</asp:Panel>
<cc1:ModalPopupExtenderID="ModalPopupExtender2"
TargetControlID="DeleteAreaButton"
PopupControlID="DeletePanel"
runat="server"
BackgroundCssClass="modalBackground"
DropShadow="true"
OkControlID="DeleteOKBtn"
CancelControlID="DeleteCancelBtn"/>
</div>

I want the OK button to submit to server, but my "protectedvoid DeleteOKBtn_Click(object sender,EventArgs e)" method is never called.
What am I doing wrong?

I know you that it looks like sort of confirmation popup, but later I would like the user to enter a value in the popup, and to be able to use the value in the server - is it doable?
Am I using the right control, or can you recommend on a better way to gain that.

Thanks in advance!

Tamir

What

Remove the OkControlID="DeleteOKBtn" property, after that your button should submit back to the page.

Contrary to the documentation the OkControlID property will cause the button click to fire off thejavascript function which is defined in OnClick. The same is true for the CancelControlID property, if you do not define it the button will post back normally.

No comments:

Post a Comment