0

May i know how to pass more than one parameter to the javascript? In my code, a new window will open after i click on a link inside a gridview. The first parameter(ID) can be successfully but i not sure how to pass in the second parameter(Name). The following code is how i try to pass the params to the javascript

 function OpenWin(id, name) {
        window.open("JHProducts.asp?ID=" + id + "&Name=" + name");
 }


<asp:TemplateField>
      <ItemTemplate>
         <a onclick='<%# String.Format("javascript:OpenWin(""{0}"");", Eval("ID"), Eval("Name"))%>' href="javascript:void(0);" style="cursor:Pointer; color: #0000CC;" >Show Details</a> 
      </ItemTemplate>
 </asp:TemplateField>   
2
  • You would be much better off adding a Hyperlink field if all you want to do is open another page : <asp:HyperLinkField DataNavigateUrlFields="ID,Name" DataNavigateUrlFormatString="JHProducts.asp?ID={0}&amp;Name={1}" /> Commented Sep 25, 2013 at 10:10
  • @Nunners , I think you'll need to add Target attribute? Commented Sep 25, 2013 at 12:09

2 Answers 2

1

Is it this or I haven't understood correctly ?

<a onclick='<%# String.Format("javascript:OpenWin('{0}','{1}');", Eval("ID"), Eval("Name"))%>' href="javascript:void(0);" style="cursor:Pointer; color: #0000CC;" >Show Details</a> 
Sign up to request clarification or add additional context in comments.

Comments

0

Try

<a onclick='javascript:Open(<%# Eval("DocTypeCode") %>)" >A_<%# Eval("Id") %></a>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.