944,068 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 2111
  • ASP.NET RSS
Oct 30th, 2009
0

/forums/clientscript.RegisterClientScriptBlock doesnot work in UpdatePanel

Expand Post »
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 :

ASP.NET Syntax (Toggle Plain Text)
  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??
Reputation Points: 8
Solved Threads: 1
Light Poster
mania_comp is offline Offline
44 posts
since Jul 2009
Apr 6th, 2010
0
Re: /forums/clientscript.RegisterClientScriptBlock doesnot work in UpdatePanel
/forums/clientscriptManager class does not work inside UpdatePanel. Use the ScriptManager class instead.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
WebMiller is offline Offline
1 posts
since Apr 2010
Aug 26th, 2011
0
Re: /forums/clientscript.RegisterClientScriptBlock doesnot work in UpdatePanel
try the folllowing code it will dafinately work

ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), Guid.NewGuid().ToString(), "alert('" "')", true);
Reputation Points: 10
Solved Threads: 0
Newbie Poster
anilkumarthumma is offline Offline
1 posts
since Aug 2011

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Expose a IIS 6 intranet site to users outside company network
Next Thread in ASP.NET Forum Timeline: how to deserilized json in asp.net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC