I am adding an onclick event from code behind file to a hyperlink control. I am trying to call a javascript function ViewInModal from this onclick event. I am picking up a value from a grid view and passing it to the javascript function. But the function is not getting triggered. I am using the following line of code.

 hypLink1.Attributes.Add("onclick", "ViewInModal("+ DataBinder.Eval(e.Row.DataItem, "ViewSome").ToString()+")");

Is there anything wrong in this line? Please help guys

  • @AmalHashim I called the function without any parameter before and the function was getting called but after I made my function to accept a parameter it is not working
    – A Beginner
    Commented May 11, 2015 at 18:28

1 Answer 1


Try changing as below

hypLink1.Attributes.Add("onclick", "ViewInModal('"+ DataBinder.Eval(e.Row.DataItem, "ViewSome").ToString()+"')");

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.