Question

For all of my hyperlinks I keep getting this error and not really sure why.

I have looked at all of the other questions that are similar but nothing really has helped.

Here is the format of the hyperlinks that keep throwing this error.

<asp:HyperLink id="BuyLink" runat="server" NavigateUrl='<%# Application["ApplicationPath"].ToString() + "/StoreModules/AddToCart.aspx?PID=" + DataBinder.Eval(Container.DataItem,"ProductID").ToString() %>' ImageUrl='<%# Application["CommonImages"] + "buy_btn.gif" %>' />

Thanks in advance!

Was it helpful?

Solution

If it's acceptable to you to hard code the ImageUrl property, then this should work. Notice the ~/ at the start of the paths to get the app root folder:

<asp:HyperLink ID="BuyLink" runat="server" 
    NavigateUrl='<%# "~/StoreModules/AddToCart.aspx?PID=" + DataBinder.Eval(Container.DataItem, "ProductID").ToString() %>' 
    ImageUrl="~/CommonImagesFolder/buy_btn.gif" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top