c# - Response.Redirect eliminates the script manager action -
i have following problem. have 1 form input customer data. after that, form give user message indicate has been done successfully:
scriptmanager.registerstartupscript(this, gettype(), "success", "alert('successfully input');", true); then, reload page using following:
response.redirect("customer_data.aspx"); the problem have first command not work if put second one. if remove second one, works fine. have tried use:
try { scriptmanager.registerstartupscript(this, gettype(), "success", "alert('successfully input');", true); } { response.redirect("customer_data.aspx"); } but again first command not work. please help.
that's because asp.net shields understanding happens on client
response.redirect("customer_data.aspx"); sends out http header
location=customer_data.aspx and
scriptmanager.registerstartupscript(this, gettype(), "success", "alert('successfully input');", true); renders
<script type="text/javascript"> alert('successfully input'); </script> at end of page. naturally if location set in http header, browser performs redirect , scripts on page not executed. can perform redirection in javascript after displaying alert:
scriptmanager.registerstartupscript(this, gettype(), "success", "alert('successfully input');location.href='customer_data.aspx'", true);
Comments
Post a Comment