ASP.Net Button with PostBackUrl Alternative

I'm creating a disclaimer page where the user has to accept the agreement to continue I started with the following:

<asp:Button ID="Button1" runat="server" Font-Names="Trebuchet MS" PostBackUrl="" Text="Click to Accept" Width="150px" />
and got this error: "The requested method post is not allowed for the url."

I researched and found different recommendations for javascript methods etc. which made no sense to me. If a hyperlink would work why couldn't a button work with it without additional scripting?

I ended up manually creating a button in an external program and doing this:

<asp:HyperLink ID="HyperLink2" runat="server" ImageUrl="~/images/accept.jpg" NavigateUrl=""></asp:HyperLink>

But seriously.... please tell me Visual Studio has a better method without requiring an additional script, or creating my own button, that doesn't involve a postback.

Any suggestions would be appreciated. (I'd even be happy if they had a simpler method of the button creation process.)
Who is Participating?
masterpassConnect With a Mentor Commented:
PostBackUrl is suppoted in the Button control

Have a look :

make sure you have the form action enabled for the page you are trying to load
Amandeep Singh BhullarCommented:
ASP Button do not PostBackURL, if you want to open a page, then you must use Hyperlink
JB4375Author Commented:
Just seems like an obvious method that would exist. I was sure I was missing something.
drypzConnect With a Mentor Commented:
Hi! In your page load event, add this

Button1.Attributes.Add("onclick", "'','yahoo'); return false;")
JB4375Author Commented:
@Masterpass: We're actually using IIS, but I do have some personal pages that use Apache. I'm sure this will come up at some point. Thanks!!

@Drypz: Very concise solution. Very nice, Thanks!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.