Hi,
I tried using ScriptManager.RegisterClientScriptBlock() i got javascript error, Syntax Error.
Protected Sub GridView1_RowCommand(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.GridViewCommandEventArgs)Handles GridView1.RowCommandIf e.CommandName ="Print"Then Dim indexAs Int16 index = Int16.Parse(e.CommandArgument.ToString())Dim valueAs String value = GridView1.Rows(index).Cells(0).TextDim scriptAs String script ="<script>window.open('Printslip.aspx?index=" + value + "');</script>" ScriptManager.RegisterClientScriptBlock(Me, GetType(Page), "Javascript", script,True)End If End Sub
bjory:
Hi,
I tried using ScriptManager.RegisterClientScriptBlock() i got javascript error, Syntax Error.
...Dim scriptAs String script ="<script>window.open('Printslip.aspx?index=" + value + "');</script>" ScriptManager.RegisterClientScriptBlock(Me, GetType(Page), "Javascript", script,True)...
bjory:
Hi,
I tried using ScriptManager.RegisterClientScriptBlock() i got javascript error, Syntax Error.
...Dim scriptAs String script ="<script>window.open('Printslip.aspx?index=" + value + "');</script>" ScriptManager.RegisterClientScriptBlock(Me, GetType(Page), "Javascript", script,True)...
The underlined code is where your error is happening. The last parameter to ScriptManager.RegisterClientScriptBlock tells the method whether or not to add <script> tags. So what your current code is doing is:
<script> <script> //adding javascript code here. </script></script>
The reason for passing "True" as the last parameter is simple, though; if you register more than one script, the call to RegisterClientScriptBlock adds only a single set of <script> tags around the entire set of javascript, which could save a lot of bandwidth depending on the complexity of your page.
Simply remove all <script> tags from your existing javascript code that is being added through this method.
Hi,
I have a user control which will display city and state when zip is given. Script manager is in the main page and update panel is in the user control. If user enters the invalid zip code I want to show the javascript pop up saying invalid zip. For that I am using
ScriptManager.RegisterClientScriptBlock(Me,GetType(Page),"test","alert('test');",True)
It does not get fire when I put it inside user control. But if it is in regular page then alert fires. Is there a way to fire the alert from user control if it gets the work input.
Thanks in advance for any suggestion, sample code or reference,
Thank You,
Nepalaya
0 件のコメント:
コメントを投稿