Search code examples
asp.netxpathonclientclick

how to pass Xpath value in javascript function


here my code that gives error-

OnClientClick='javascript:DragRevId(<%# XPath("ReservationId") %>);return false;'

Solution

  • It probably has something to do with the fact that XPath's use the '\' character. You'll need to escape that character if you want to use it with javascript.

    Example: Node\Child --> Node\\Child

    So, within ASP, do a String.Replace('\', "\\"); or something similar.

    If this doesn't work you might want to consider posting the error that is thrown, and specifying if it is an ASP.Net error or a Javascript error.