I need to call the following programatically to set something up when a modal popup is shown.
Sys.Application.add_load(modalSetup);
Something along the lines.
<script type='text/javascript'>
Sys.Application.add_load(modalSetup);
function modalSetup() {
var modalPopup = $find("PopupBehaviorId");
if (modalPopup != null) {
modalPopup.add_shown(SetFocusOnControl);
}
}
function SetFocusOnControl() {
alert('test');
}
</script>
Now the problem is that I have a script manager
on the master page.
If I put this script manually (not programatically) below the script manager in the master page
, it will work correctly.
But when I'm adding this programatically in the user control for modal popup (which I need to) using either ScriptManager.RegisterClientScriptBlock or Page.ClientScript.RegisterClientScriptBlock
, it throws the famous sys is undefined
error.
I know this is happening because this programatic injection puts it into the Head section
before the ScriptManager
line is executed.
How can I get around this. Is it possible to say insert this script at the end of the page and not at the top?
I need to call the following programatically to set something up when a modal popup is shown.
Sys.Application.add_load(modalSetup);
Something along the lines.
<script type='text/javascript'>
Sys.Application.add_load(modalSetup);
function modalSetup() {
var modalPopup = $find("PopupBehaviorId");
if (modalPopup != null) {
modalPopup.add_shown(SetFocusOnControl);
}
}
function SetFocusOnControl() {
alert('test');
}
</script>
Now the problem is that I have a script manager
on the master page.
If I put this script manually (not programatically) below the script manager in the master page
, it will work correctly.
But when I'm adding this programatically in the user control for modal popup (which I need to) using either ScriptManager.RegisterClientScriptBlock or Page.ClientScript.RegisterClientScriptBlock
, it throws the famous sys is undefined
error.
I know this is happening because this programatic injection puts it into the Head section
before the ScriptManager
line is executed.
How can I get around this. Is it possible to say insert this script at the end of the page and not at the top?
Share Improve this question edited Mar 29, 2021 at 8:13 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Oct 11, 2011 at 22:27 Alex JAlex J 1,5673 gold badges26 silver badges42 bronze badges1 Answer
Reset to default 5 +100You can use ScriptManager's RegisterStartupScript method.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745642792a4637792.html
评论列表(0条)