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="http://74.125.159.103/mypage/" 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="http://74.125.159.103/mypage/"></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.)
LVL 1
JB4375Asked:
Who is Participating?
 
masterpassConnect With a Mentor Commented:
PostBackUrl is suppoted in the Button control

Have a look : http://www.experts-exchange.com/Web/Web_Servers/Apache/Q_20833978.html

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

Button1.Attributes.Add("onclick", "window.open('http://www.yahoo.com','yahoo'); return false;")
0
 
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!!
0
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.