Wednesday, 30 May 2012

[solved] ScripManager Error in UpdatePanel



My Code: (NewPage_aspx.cs)
protected void textbox1_TextChanged(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "    alert('Error !!!');", false);
}


The Error Come out during Debuging: 
'Sys.WebForms.PageRequestManagerServerErrorException:  Sys.WebForms.PageRequestManagerServerErrorException:  The script tag registered for type  'ASP.NewPage_aspx'  and key 'd2977ac5-6732-43dd-8828-2f5d1b290173'  has invalid characters outside of the  script tags: alert('Error !!!');. Only properly formatted script tags can be registered.'  when calling method: [nsIDOMEventListener::handleEvent]


Solution:
After do some research about this error at online, I find out that this error occurred may because of the textbox1 is in the UpdatePanel


So, I add some code in the page (NewPage_aspx): 


<script language="javascript" type="text/javascript" id="forModalPopUp">
var prm =  Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);


function InitializeRequest(sender, args) {
}
function EndRequest(sender, args) {
}
</script>

No comments:

Post a Comment

If you are not a member of blogspot or Google. leave your email or name, so I can easier to contact you. Thanks. ^^