I have ASCX control, that basically contains just a DIV with few ASP buttons inside. My Master Page contains an ASP.NET form, that I want to cause postback when one of aforementioned buttons are pressed. This DIV is invisible by default and becomes visible to serve as a dialog, which is handled by JQuery plugin BlockUI. So, at some point user will see this DIV and I want a postback to happen when user clicks button.
My problem is: the ASCX is attached to MasterPage via direcitve:
(file MasterPage begins:)
<%@ Master Language="C#" Inherits="GIUMasterPage" CodeBehind="MasterPage.master.cs"
AutoEventWireup="True" %>
<%@ Register Src="uscMsgBox.ascx" TagName="uscMsgBox" TagPrefix="uc2" %>
(HTML head, body form opening tags are below).
Examination of the page shows that its DIV appears at the end of resulting HTML code outside the form tag. In result, when it is visible and button is hit, postback did not happened. I went further, attaching on button’s onClientClick property javascript call to __doPostBack function. Postback started to happen, but there was no invocation of button’s handlers.
I am sure that if ASCX’s DIV code will appear within form HTML tags, postback will happen as proper.
So, my question is, how I can command to put ASPX’s DIV content within FORM tags, not at the end of page, by some directive? I may alter MasterPage and ASPX itself.
The jQuery UI Dialog moves itself to the end of the body, outside of your form. The trick is to move the dialog div back inside your form when you open it.
See https://stackoverflow.com/a/1140541/26226 and http://blog.roonga.com.au/2009/07/using-jquery-ui-dialog-with-aspnet-and.html.