- Get link
- X
- Other Apps
- Get link
- X
- Other Apps
In this article I will explain how to show javascript confirm alert popup in Asp.Net from the server side using C# and VB.Net. Here you can show the javascript alert popup in different events on page load and button submit.
Show confirm message when users submit the page (Page Load Event):
In the Page Loading event, the following JavaScript function will be recorded using the RegisterOnSubmitStatement function. The below javascript function display a confirm message to the user in a javascript alert popup. It will show the confirm message to the user when a user submits the page.
C#
protected void Page_Load(object sender, EventArgs e) { string message = "Do you want to Submit?"; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("return confirm('"); sb.Append(message); sb.Append("');"); ClientScript.RegisterOnSubmitStatement(this.GetType(), "alert", sb.ToString()); }
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Dim message = "Do you want to Submit?" Dim sb As StringBuilder = New StringBuilder() sb.Append("return confirm('") sb.Append(message) sb.Append("');") ClientScript.RegisterOnSubmitStatement([GetType](), "alert", sb.ToString()) End Sub
Please mail me at hemanta@webcodespider.net if you want any code solution from me.
Thank You 😊
Show Javascript Alert Message in ASP.Net from Server Side using C# and VB.Net
- Get link
- X
- Other Apps
Comments
Post a Comment