Search code examples
asp.netvb.netnavigateurl

html parser error message: Parser Error Message: The server tag is not well formed


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?


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());
    }