0

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!

DGibbs
  • 14,316
  • 7
  • 44
  • 83
Robert Zeno
  • 67
  • 1
  • 14
  • What's wrong with setting the `NavigateUrl` and `ImageUrl` properties in the code behind? I suspect this is where the issue is. It would be a lot easier to debug if they were set in code – DGibbs Apr 11 '13 at 16:15
  • The only reason I had not done it in the code behind was because this is an .net 1.1 site that I am upgrading to .net 4.0 and was just trying to preserve the code. Doing it in the code behind was my last resort haha Also these hyperlinks are in asp:datagrids @DGibbs – Robert Zeno Apr 11 '13 at 16:24
  • I'd move that inline code to the code behind personally, it _may_ not be the issue but if you're upgrading to 4.0 i see no reason not to do this at the same time. Think of the poor soul that has to maintain it! – DGibbs Apr 11 '13 at 16:27

1 Answers1

0

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" />
Netricity
  • 2,550
  • 1
  • 22
  • 28