/forums/clientscript.RegisterClientScriptBlock doesnot work in UpdatePanel

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2009
Posts: 42
Reputation: mania_comp is an unknown quantity at this point 
Solved Threads: 1
mania_comp mania_comp is offline Offline
Light Poster

/forums/clientscript.RegisterClientScriptBlock doesnot work in UpdatePanel

 
0
  #1
Oct 30th, 2009
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 :

  1. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2. TextBox1.Text = "I Enjoy ASP.NET"
  3.  
  4. Dim myscript As String = "alert(document.getElementById('TextBox1').value);"
  5. Page.ClientScript.RegisterStartupScript(Me.GetType(), "myscript", myscript, True)
  6. End Sub
  7.  
  8. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  9. Dim strMessage As String
  10. strMessage = "Hi, You clicked ClickMe button"
  11. Dim strScript As String = "<script language=JavaScript>"
  12. strScript += "alert('" & strMessage & "');"
  13. strScript += "</script>"
  14.  
  15. If (Not ClientScript.IsStartupScriptRegistered("clientScript")) Then
  16. ClientScript.RegisterClientScriptBlock(Me.GetType(), "clientScript", strScript)
  17. End If
  18. 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??
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC