0

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??

3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by anilkumarthumma
0

/forums/clientscriptManager class does not work inside UpdatePanel. Use the ScriptManager class instead.

0

try the folllowing code it will dafinately work

ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), Guid.NewGuid().ToString(), "alert('" "')", true);

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.