0

I am trying to pass a row index to my javascript function using the below line that resides inside the gridview, but I keep getting an error.

Below is my code.

<asp:TemplateField HeaderText="MCLID"> 
    <ItemTemplate> 
        <label style="text-decoration: underline"
         onclick="javascript:warningMessage('<%# Eval("ID") %>','<%# Eval("systempath").ToString().Replace("'",@"\'") %>','<%# Eval("root_level") %>','<%# Eval("Parentid") %>','<%# Eval(Container.DataItemIndex +1) %>');"><%#Eval("ID") %></label> 
    </ItemTemplate> 
</asp:TemplateField>

any help will be appreciated.

2
  • 1
    Post the relevant part of what you get in the browser (i.e. what does the above actually generate). What error do you get? Where do you get it, on the server or at the client? Commented Nov 28, 2012 at 23:26
  • what is the error? Post your js function too. Commented Nov 29, 2012 at 5:38

1 Answer 1

3

Instead of:

onclick="javascript:warningMessage('<%# Eval("ID") %>','<%# Eval("systempath").ToString().Replace("'",@"\'") %>','<%# Eval("root_level") %>','<%# Eval("Parentid") %>','<%# Eval(Container.DataItemIndex +1) %>');"

Try using something like:

onclick='<%# "javascript:warningMessage('" + Eval("ID").ToString() + "'" %>'
Sign up to request clarification or add additional context in comments.

1 Comment

Yup, that'd be the problem... premature js eval. Good pickup.

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.