Saturday, March 24, 2012

ModalPopExtender, Javascript & Master page

Hi

I googled about this problem and never found an answer. Everybody is complaining about it but nobody found any solution. I thought I will put the problem in this forum so some AJAX Guru can research and help us.

Here is the problem,

Whenever you use the ModalPopExtender and try to do something during begin of the postback or at the end of post back via javascript. It works fine in the single page. But as soon you add a master page, it doesn't work. It either says "null, null object not found" or object not found.. Whats the problem when its master page

<scripttype="text/javascript">

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);

function beginRequest(sender, args){

// show the popup

alert("here0");

var cmb = $find('mdlPopup');

//alert("here");

//find$('<%= mdlPopup.ClientID %>').show();

//var cmb = document.getElementByName('<%= mdlPopup.ClientID %>');

//var cmb = document.getElementByName(GetClientId("mdlPopup"));

if (cmb !=null) {

cmb.show();

alert("here2");

}

}

function endRequest(sender, args) {

// hide the popup

alert("here3");

$find('mdlPopup').hide();

}

</script>

<asp:UpdatePanelID="updatePanel2"runat="server">

<ContentTemplate>

<table>

<tr>

<td>

Signature:</td>

<td>

<asp:TextBoxID="signatureText"runat="server"/></td>

</tr>

<tr>

<td>

Bio:</td>

<td>

<asp:TextBoxID="bioText"runat="server"/></td>

</tr>

</table>

<asp:ButtonID="Button3"runat="Server"Text="Save"/>

<asp:LinkbuttonID="Button1"runat="Server"Text="Save"/>

<br/><br/>

Hit Save to cause a postback from an update panel inside the tab panel.<br/>

</div>

</ContentTemplate>

</asp:UpdatePanel>

<ajaxToolKit:ModalPopupExtender

ID="mdlPopup"runat="server"TargetControlID="pnlPopup"

PopupControlID="pnlPopup"BackgroundCssClass="modalBackground"/>

<asp:PanelID="pnlPopup"runat="server"CssClass="updateProgress"style="display:none">

<divalign="center"style="margin-top:13px;">

<imgsrc="../Images/simple.gif"/>

<spanclass="updateProgressMessage">Loading ...</span>

</div>

</asp:Panel>

It will really help if somebody finds a solution for it..

VIJAI

Hi,

Thank you for your post!

This works on my machine:

<script type="text/javascript">
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);
function beginRequest(sender, args){
alert("here0");
var cmb = $find('<%=mdlPopup.ClientID %>');
cmb.show();
alert("here2");
}
function endRequest(sender, args) {
alert("here3");
$find('<%=mdlPopup.ClientID %>').hide();
}

</script>

If yo have further questions,let me know!

Best Regards,

No comments:

Post a Comment