I have a control if a review already exist, if it exist I want to warn the visitor that if the person click OK/yes in the alert the review will be overwritten, if the person press no/cancel the review will not be updated. But it doesn’t work, in the debugging the alert line just passes by and updates without any alert.
if (ReviewExist(StoreID, UserID) != 0)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Message", "confirm('Are you sure?');", true);
UpdateStoreReview(Description);
Response.Redirect("Default");
}
else
{
AddStoreReview(Description);
}
It is because your
Response.Redirectredirects the control to another page which will ignore yourRegisterScript.What you need to do is, if you are trying to acheive this in the button click (update button), then in the Page_Load try
Then the above code can be changed to
Note
I think you need to redirect to Default.aspx; but you are missing .aspx in the
response.redirect.