Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 686
  • Last Modified:

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

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
VBBRett
Asked:
VBBRett
2 Solutions
 
tillgeffkenCommented:
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
 
VBBRettAuthor Commented:
Yes, it is my goal to redirect or open the main page of the other site.
0
 
ajollyCommented:
use

OnClientClick="window.location='http://www.rmag.com'; return false;"
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
VBBRettAuthor Commented:
That didn't work out too well.  All it did was just shift the page and make me stay on that same page.
0
 
VBBRettAuthor Commented:
This should be a simple task, how do I do this without all the problems?
0
 
tillgeffkenCommented:
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
 
GuitarRichCommented:
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
 
tillgeffkenCommented:
Although that approach will make functionality inaccessible from code behind. Yeah, i know that the image button was missing a runat="server" property =)
0
 
VBBRettAuthor Commented:
Thank you very much gentlemen!
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.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now