Here is what I have tried.
ASPX File:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button OnClick="btnOK1_Click" ID="btnOK1" runat="server" Text="Save" />
</ContentTemplate>
</asp:UpdatePanel>
ASPX.VB:
Protected Sub btnOK1_Click(sender As Object, e As EventArgs)
Dim alertMsg As String
Dim alertScript As String
alertMsg = String.Format("You Selected {0}", "My Message")
alertScript = String.Format("<script type= text/javascript>alert('{0}');</script>", alertMsg)
ClientScript.RegisterStartupScript(Me.[GetType](), "Alert", alertScript)
End Sub
I tried to get an alert box with a message when clicked a button (Save) from backend. I tried with the solutions from the StackOverflow. But, the codes does not work for me to get an javascript alert box. The event triggers fine and runs through the code. Anyone help me with this?