I am using ModalPopup extender in my application, with this extender I created a progress bar, it works fine without using a Masterpage in my webform, but when I use my webform in a MasterPage doesn't work out, I tried to solve this problem moving the javascript
code to the Masterpage, but it doesn't work, I don't know how to make my Modalpopup extender works fine in my webform with a MasterPage. If somebody knows how to solve this or has anyother idea I would be thankful. following I put all of the code without using
a MasterPage. I receive a javascript code: 'null' is null or not an object
add this script to ur master page and refer this code
<script type="text/javascript">
Sys.Application.add_load(GlobalApplicationLoadHandler);
function GlobalApplicationLoadHandler(sender, args) {
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (!prm.get_isInAsyncPostBack()) {
prm.add_initializeRequest(initRequest);
prm.add_endRequest(endRequest);
}
}
function initRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtender.ClientID%>");
pop.show();
}
function endRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtender.ClientID%>");
pop.hide();
}
</script>
Please put all the codes in the masterpage.So the benefit is Any webpage( this master added) having pastback the processing(modal popup extender) will display.
Please, Mark as Answer if this reply helped you
Harikrishnan.S
I put all of the code in masterpage and receive an error: do I have to put something in Webconfig?
Object reference not set to an instance of an object.
Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 18: }
Line 19: function initRequest(sender, args) {
Line 20: var pop = $find("<%=GlobalModalPopupExtender.ClientID%>");
Line 21: pop.show();
Line 22: }
If you use the MasterPage, the best way to find the client behavior is using the BehaviorID as the $find method’s parameter:
$find(‘the ModalPopupExtender’s BehaviorID’)
Best regards,
Zhi-Qiang Ni
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
Answer” if a marked post does not actually answer your question.
I put BehaviorID in my code and it does not work out, I put the following code and I received and error, afterwards of the error message is all of the code I put in Masterpage, please help me I don't know what I have to change in the code.
Thank you in advance.
Best regards Christian.
Compilation Error
Description:
An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: Name 'GlobalModalPopupExtenderWeb' is not declared.
Source Error:
Line 18: }
Line 19: function initRequest(sender, args) {
Line 20: var pop = $find("<%=GlobalModalPopupExtenderWeb%>");
Line 21: pop.show();
Line 22: }
<script type="text/javascript">
Sys.Application.add_load(GlobalApplicationLoadHandler);
function GlobalApplicationLoadHandler(sender, args) {
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (!prm.get_isInAsyncPostBack()) {
prm.add_initializeRequest(initRequest);
prm.add_endRequest(endRequest);
}
}
function initRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtenderWeb%>");
pop.show();
}
function endRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtenderWeb%>");
pop.hide();
}
</script>
function initRequest(sender, args) {
var pop = $find(‘mpe’);
pop.show();
}
Best regards,
Zhi-Qiang Ni
Microsoft Online Community Support
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
Answer” if a marked post does not actually answer your question.
<script type="text/javascript">
Sys.Application.add_load(GlobalApplicationLoadHandler);
function GlobalApplicationLoadHandler(sender, args) {
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (!prm.get_isInAsyncPostBack()) {
prm.add_initializeRequest(initRequest);
prm.add_endRequest(endRequest);
}
}
function initRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtender.ClientID%>");
pop.show();
}
function endRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtender.ClientID%>");
pop.hide();
}
</script>
</form>
Surely it will help you
Please, Mark as Answer if this reply helped you
Harikrishnan.S
Hello, thank you for your time, I don't know what it is wrong.
I put all of the code that you mentioned in the masterpage and I put the javascript code inside the form, and it doesn't work out, the modalpup extender doesn't show up during the asyncronous call when I click over the Button1 in web form , in web form
I put only this code:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
System.Threading.Thread.Sleep(3000)
End Sub
<script type="text/javascript">
Sys.Application.add_load(GlobalApplicationLoadHandler);
function GlobalApplicationLoadHandler(sender, args) {
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (!prm.get_isInAsyncPostBack()) {
prm.add_initializeRequest(initRequest);
prm.add_endRequest(endRequest);
}
}
function initRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtender.ClientID%>");
pop.show();
}
function endRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtender.ClientID%>");
pop.hide();
}
</script>
Christianpmg
Member
73 Points
59 Posts
Javascript error 'null' is null or not an object in Modalpopup extender
Jul 09, 2009 01:35 AM|LINK
Hello everybody, my name is Christian.
I am using ModalPopup extender in my application, with this extender I created a progress bar, it works fine without using a Masterpage in my webform, but when I use my webform in a MasterPage doesn't work out, I tried to solve this problem moving the javascript code to the Masterpage, but it doesn't work, I don't know how to make my Modalpopup extender works fine in my webform with a MasterPage. If somebody knows how to solve this or has anyother idea I would be thankful. following I put all of the code without using a MasterPage. I receive a javascript code: 'null' is null or not an object
thank you in advance.
best regards.
Christian.
<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server" />
<script type="text/javascript" language="javascript">
// CAPTURE EVENTS
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(endRequest);
function beginRequest(sender, args) {
$find('ModalProgress').show();
}
function endRequest(sender, args) {
// BEGIN POSTBACK EVENT
$find('ModalProgress').hide();
}
</script>
<script runat="server">
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
System.Threading.Thread.Sleep(3000)
End Sub
</script>
<asp:UpdatePanel ID="Ejemplo" runat="server" UpdateMode="Conditional">
<ContentTemplate>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<asp:Button ID="Button1" runat="server" Text="Button" />
<ajaxToolkit:ModalPopupExtender ID="ModalProgress" runat="server"
TargetControlID="Fntr_Popup" PopupControlID="Fntr_Popup" BackgroundCssClass="backgroundprogressbar">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="Fntr_Popup" runat="server" CssClass="progressbar" style="display:none">
please wait or/o por favor espere ...
<img src="loading.gif" alt="" title=""/>
</asp:Panel>
<br />
</form>
</body>
</html>
harieis
Participant
782 Points
242 Posts
Re: Javascript error 'null' is null or not an object in Modalpopup extender
Jul 09, 2009 03:50 AM|LINK
add this script to ur master page and refer this code
<script type="text/javascript">
Sys.Application.add_load(GlobalApplicationLoadHandler);
function GlobalApplicationLoadHandler(sender, args) {
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (!prm.get_isInAsyncPostBack()) {
prm.add_initializeRequest(initRequest);
prm.add_endRequest(endRequest);
}
}
function initRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtender.ClientID%>");
pop.show();
}
function endRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtender.ClientID%>");
pop.hide();
}
</script>
Add this
<div id="GlobalMain" runat="server">
<asp:ScriptManager ID="ScriptManager1"
runat="server" EnableScriptGlobalization="true" >
</asp:ScriptManager>
</div>
<cc1:ModalPopupExtender ID="GlobalModalPopupExtender" runat="server" PopupControlID="GlobalpnlPopup"
DropShadow="False" TargetControlID="GlobalMain" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="GlobalpnlPopup" runat="server" Style="display: none; background-color: #EEF1F1;
border-width: 1px; border-style: solid; width: 200px; border-color: Black; padding: 2px">
<table align="center">
<tr>
<td align="center">
<asp:Image ID="imgGlobalProcessing" runat="server" ImageUrl="Your ImageURL"/>
Processing ...
</td>
</tr>
</table>
</asp:Panel>
Harikrishnan.S
Christianpmg
Member
73 Points
59 Posts
Re: Javascript error 'null' is null or not an object in Modalpopup extender
Jul 09, 2009 08:34 PM|LINK
Hello.
The first part of your code I put in the Masterpage, the second one in the webform and it doesn't work out, can you explain me a little bit more?
Thank you in advance.
best regards.
Christian.
harieis
Participant
782 Points
242 Posts
Re: Javascript error 'null' is null or not an object in Modalpopup extender
Jul 10, 2009 03:49 AM|LINK
Hello
Please put all the codes in the masterpage.So the benefit is Any webpage( this master added) having pastback the processing(modal popup extender) will display.
Harikrishnan.S
Christianpmg
Member
73 Points
59 Posts
Re: Javascript error 'null' is null or not an object in Modalpopup extender
Jul 12, 2009 11:02 PM|LINK
Hello.
I put all of the code in masterpage and receive an error: do I have to put something in Webconfig?
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Thank you in advance.
Christian.
Zhi-Qiang Ni...
All-Star
33491 Points
2952 Posts
Microsoft
Re: Javascript error 'null' is null or not an object in Modalpopup extender
Jul 13, 2009 10:02 AM|LINK
Hi Christian,
If you use the MasterPage, the best way to find the client behavior is using the BehaviorID as the $find method’s parameter:
$find(‘the ModalPopupExtender’s BehaviorID’)
Best regards,
Zhi-Qiang Ni
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
Answer” if a marked post does not actually answer your question.
Christianpmg
Member
73 Points
59 Posts
Re: Javascript error 'null' is null or not an object in Modalpopup extender
Jul 14, 2009 03:31 AM|LINK
Hello Zhi-Qiang Ni.
I put BehaviorID in my code and it does not work out, I put the following code and I received and error, afterwards of the error message is all of the code I put in Masterpage, please help me I don't know what I have to change in the code.
Thank you in advance.
Best regards Christian.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: Name 'GlobalModalPopupExtenderWeb' is not declared.
Source Error:
following the code:
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Prueba.master.vb" Inherits="WebApplication1.Prueba" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<script type="text/javascript">
Sys.Application.add_load(GlobalApplicationLoadHandler);
function GlobalApplicationLoadHandler(sender, args) {
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (!prm.get_isInAsyncPostBack()) {
prm.add_initializeRequest(initRequest);
prm.add_endRequest(endRequest);
}
}
function initRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtenderWeb%>");
pop.show();
}
function endRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtenderWeb%>");
pop.hide();
}
</script>
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
<asp:ScriptManager ID="ScriptManager1"
runat="server" EnableScriptGlobalization="true" >
</asp:ScriptManager>
<cc1:ModalPopupExtender ID="GlobalModalPopupExtender" runat="server" PopupControlID="GlobalpnlPopup"
DropShadow="False" TargetControlID="GlobalMain" BackgroundCssClass="modalBackground" BehaviorID="GlobalModalPopupExtenderWeb" >
</cc1:ModalPopupExtender>
<asp:Panel ID="GlobalpnlPopup" runat="server" Style="display: none; background-color: #EEF1F1;
border-width: 1px; border-style: solid; width: 200px; border-color: Black; padding: 2px">
<table align="center">
<tr>
<td align="center">
<asp:Image ID="imgGlobalProcessing" runat="server" ImageUrl="progress.gif"/>
Processing ...
</td>
</tr>
</table>
</asp:Panel>
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Zhi-Qiang Ni...
All-Star
33491 Points
2952 Posts
Microsoft
Re: Javascript error 'null' is null or not an object in Modalpopup extender
Jul 14, 2009 03:47 AM|LINK
Hi Christian,
Maybe I have not provided a detailed suggestion. Well, use this code:
<cc1:ModalPopupExtender ID="GlobalModalPopupExtender" BehaviorID=”mpe” runat="server" PopupControlID="GlobalpnlPopup"
DropShadow="False" TargetControlID="GlobalMain" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
function initRequest(sender, args) {
var pop = $find(‘mpe’);
pop.show();
}
Best regards,
Zhi-Qiang Ni
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as
Answer” if a marked post does not actually answer your question.
harieis
Participant
782 Points
242 Posts
Re: Javascript error 'null' is null or not an object in Modalpopup extender
Jul 14, 2009 04:03 AM|LINK
Hello
Do first : Please remove the java script from the header tag.And add in the form tag
please refer this code
<form id="form1" runat="server">
<div id="GlobalMain" runat="server">
<asp:ScriptManager ID="ScriptManager1" AsyncPostBackErrorMessage="Connection with the server was lost. Please try again"
runat="server" EnablePartialRendering="true" EnablePageMethods="True" EnableScriptGlobalization="true"
EnableScriptLocalization="true">
</asp:ScriptManager>
</div>
<cc1:ModalPopupExtender ID="GlobalModalPopupExtender" runat="server" PopupControlID="GlobalpnlPopup"
DropShadow="False" TargetControlID="GlobalMain" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="GlobalpnlPopup" runat="server" Style="display: none; background-color: #EEF1F1;
border-width: 1px; border-style: solid; width: 200px; border-color: Black; padding: 2px">
<table align="center">
<tr>
<td align="center">
<asp:Image ID="imgGlobalProcessing" runat="server" ImagURL="YOUR_URL" />
Processing ...
</td>
</tr>
</table>
</asp:Panel>
<script type="text/javascript">
Sys.Application.add_load(GlobalApplicationLoadHandler);
function GlobalApplicationLoadHandler(sender, args) {
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (!prm.get_isInAsyncPostBack()) {
prm.add_initializeRequest(initRequest);
prm.add_endRequest(endRequest);
}
}
function initRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtender.ClientID%>");
pop.show();
}
function endRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtender.ClientID%>");
pop.hide();
}
</script>
</form>
Surely it will help you
Harikrishnan.S
Christianpmg
Member
73 Points
59 Posts
Re: Javascript error 'null' is null or not an object in Modalpopup extender
Jul 15, 2009 03:24 AM|LINK
Hello, thank you for your time, I don't know what it is wrong.
I put all of the code that you mentioned in the masterpage and I put the javascript code inside the form, and it doesn't work out, the modalpup extender doesn't show up during the asyncronous call when I click over the Button1 in web form , in web form I put only this code:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
System.Threading.Thread.Sleep(3000)
End Sub
In the the masterpage I put the following code:
Thank you in advance and best regards
Christian.
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Site1.master.vb" Inherits="WebApplication1.Site1" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
<div id="GlobalMain" runat="server">
<asp:ScriptManager ID="ScriptManager2" AsyncPostBackErrorMessage="Connection with the server was lost. Please try again"
runat="server" EnablePartialRendering="true" EnablePageMethods="True" EnableScriptGlobalization="true"
EnableScriptLocalization="true">
</asp:ScriptManager>
</div>
<cc1:ModalPopupExtender ID="GlobalModalPopupExtender" runat="server" PopupControlID="GlobalpnlPopup"
DropShadow="False" TargetControlID="GlobalMain" BackgroundCssClass="modalBackground">
</cc1:ModalPopupExtender>
<asp:Panel ID="GlobalpnlPopup" runat="server" Style="display: none; background-color: #EEF1F1;
border-width: 1px; border-style: solid; width: 200px; border-color: Black; padding: 2px">
<table align="center">
<tr>
<td align="center">
<asp:Image ID="imgGlobalProcessing" runat="server" ImageURL="progress.gif" />
Processing ...
</td>
</tr>
</table>
</asp:Panel>
<script type="text/javascript">
Sys.Application.add_load(GlobalApplicationLoadHandler);
function GlobalApplicationLoadHandler(sender, args) {
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (!prm.get_isInAsyncPostBack()) {
prm.add_initializeRequest(initRequest);
prm.add_endRequest(endRequest);
}
}
function initRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtender.ClientID%>");
pop.show();
}
function endRequest(sender, args) {
var pop = $find("<%=GlobalModalPopupExtender.ClientID%>");
pop.hide();
}
</script>
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>