Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

The requested method POST is not allowed for the URL /index.htm

Posted on 2009-05-12
9
Medium Priority
?
675 Views
Last Modified: 2012-05-06
OK, I am having a problem with a post method linking to another site.  When I try to do the following line of code and link it to another site, I get the following error:

The requested method POST is not allowed for the URL /index.htm

Here is the line of code that I have on my sight that I get the problem with:

<asp:ImageButton ID="ImageButton1" ImageUrl="~/images/rsamurai.jpg" style="margin-left:20px;" PostBackUrl="http://www.rmag.com" runat="server" />

Of course the PostBackURL link has been adjusted for privacy reasons, but what other solution is there for me to add a link to a website imagebutton without running into problems?  Thanks!
0
Comment
Question by:VBBRett
9 Comments
 
LVL 9

Expert Comment

by:tillgeffken
ID: 24362750
Is it your goal to post your form to the other site or just redirect? The error message is coming from the other site, right?
0
 

Author Comment

by:VBBRett
ID: 24362786
Yes, it is my goal to redirect or open the main page of the other site.
0
 
LVL 7

Expert Comment

by:ajolly
ID: 24362788
use

OnClientClick="window.location='http://www.rmag.com'; return false;"
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:VBBRett
ID: 24362816
That didn't work out too well.  All it did was just shift the page and make me stay on that same page.
0
 

Author Comment

by:VBBRett
ID: 24362885
This should be a simple task, how do I do this without all the problems?
0
 
LVL 9

Accepted Solution

by:
tillgeffken earned 1040 total points
ID: 24362922
This makes it a bit reusable:


<script type="text/javascript">
function redirectTo(url)
{
   window.location.href  = url;
   return false;
}
</script>
 
<asp:ImageButton ID="ImageButton1" ImageUrl="~/images/rsamurai.jpg" style="margin-left:20px;" OnClientClick="redirectTo('http://www.rmag.com'); return false;" />

Open in new window

0
 
LVL 12

Assisted Solution

by:GuitarRich
GuitarRich earned 960 total points
ID: 24362978
This is really simple - just use an anchor tag with an image, no need to over complicate things with postbacks or js imo.
<a href="http://www.rmag.com" style="margin-left:20px;"><asp:Image ImageUrl="~/images/rsamurai.jpg" id="image1" Runat="Server"></asp:Image></a>

Open in new window

0
 
LVL 9

Expert Comment

by:tillgeffken
ID: 24363017
Although that approach will make functionality inaccessible from code behind. Yeah, i know that the image button was missing a runat="server" property =)
0
 

Author Closing Comment

by:VBBRett
ID: 31580463
Thank you very much gentlemen!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Loops Section Overview

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question