Hi friends..
I am trying to display message box using server-side code. I have written code in buttons click event and Page Load Event. It is as follows :
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
TextBox1.Text = "I Enjoy ASP.NET"
Dim myscript As String = "alert(document.getElementById('TextBox1').value);"
Page.ClientScript.RegisterStartupScript(Me.GetType(), "myscript", myscript, True)
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strMessage As String
strMessage = "Hi, You clicked ClickMe button"
Dim strScript As String = "<script language=JavaScript>"
strScript += "alert('" & strMessage & "');"
strScript += "</script>"
If (Not ClientScript.IsStartupScriptRegistered("clientScript")) Then
ClientScript.RegisterClientScriptBlock(Me.GetType(), "clientScript", strScript)
End If
End Sub
If button is not in UPDATE PANEL, then both alert are displayed normally (i.e. during Page Load and Button Click)
But when I put the button inside UPDATE PANEL , alert dosn't work in Button Click. Here only Page_Load alert is displayed
In case of UPDATE PANEL is also tried
Me.UpdatePane1.GetType()
but in vain..!!!
Any ideas??