I want to launch a modal popup from c# code and wait for user to hit the ok button before executing the next c# line.
I tried the following
System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "script", alertMessage, true);
but it does not pause to wait for use to hit the ok button and keeps going.
I also tried this
Response.Write(@"<script language='javascript'>alert( " + alertMessage + " );</script>");
But it returning an error message
Any help is appreciated
Create a simple method on aspx page
<script type="text/javascript">
function openModal(id) {
$(id).modal('show');
}
</script>
Then call this function in code like
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal('#yourModalID');", true);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.