Search code examples
c#asp.netascx

Parser Error The server tag is not well formed


<asp:HyperLink runat="server" Text='<%# Path.GetFileName(Eval("MediaFileLink").ToString()) %>'
                NavigateUrl='<%# String.Format("http://www.someurlwithparams.com/{0}", Path.GetFileNameWithoutExtension(Eval("MediaFileLink").ToString()).Substring(0, Path.GetFileNameWithoutExtension(Eval("MediaFileLink").ToString()).IndexOf('_'))) %>' Target="_blank" />

I get the Parser Error Message: The server tag is not well formed. I already checked for missing closing tags or double quotes but somehow I miss the error.


Solution

  • IndexOf method probably causing this issue as it closes you server tag at first ' symbol. Try to change it to ToString().IndexOf("_")