Question

I am getting the error Parser Error Message: The server tag is not well formed. on the code line below:

<asp:HyperLink ID="imgFileType" ImageUrl="images/Icon_Pdf.gif" NavigateUrl='<%#"javascript:ViewFile('erg_", Eval("DocumentName") %>' runat="server"></asp:HyperLink>     

I need the url link to be parsed as:

javascript:ViewFile('erg_Invoice_3200_QRG_Restaurant.pdf');

What am I missing in the syntax?

Was it helpful?

Solution

You cannot do that. The single quote double quote mess will make the compiler complain.
Please write a helper.

Markup

NavigateUrl='<%# SetNavigateUrl(Eval("DocumentName")) %>'>

Code-Behind

protected string SetNavigateUrl(object objName)
{
    return String.Format("javascript:ViewFile('erg_{0}');", objName.ToString());
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top