0

So I have this line of code which uses a hyperlink

<asp:HyperLink style="text-decoration:none" runat="server" Text="View Order" NavigateUrl='<%# "OrderDetails2.aspx?oID=" + Eval("oID") %>'>/asp:HyperLink>

Works perfectly fine but when I try to use a button to do the same thing (since I have to use an OnClick method), it doesn't allow me to use NavigateUrl and Eval in it. Any alternative methods?

2 Answers2

0

Not sure what you're trying to do.

If you are trying to add a link to another page, just use asp:hyperlink but use CSS to make it look like a button.

If you really do want a button with a server-side click event, you can add the following to the end of the click event handler:

Response.Redirect(String.Format("OrderDetails2.aspx?oID={0}", oID));
Community
  • 1
  • 1
John Wu
  • 47,831
  • 8
  • 41
  • 73
0

Thats because asp:button does not have a property called NavigateUrl, its only a valid property for an hyperlink.

You can use JavaScript click event for an asp:hyperlink.

Polynomial Proton
  • 4,762
  • 18
  • 37