I have an asp.net page in an iframe where all links target _blank
<base target="_blank" />
But I want the form on it to submit to _self (i.e. the iframe where the page is located) when the one button is clicked. The form is an <asp:Panel> with an <asp:Button> control for submitting it.
Where can I set the target for this form? Since there isn’t a <form> tag or an <input> tag in the file (ASP.NET makes them when it renders the page), I don’t know how to change the target to override my <base> tag.
I just found this post on the asp.net forums by mokeefe that changes the target by javascript.
I just put it in my page and tried it. I had to make these modifications:
1. I’m using asp tags only, so I have
<asp:Button>not<input type="button">and my onclick has to be the server-side method I’m calling on submission. Therefore I put this new javascript in OnClientClick:2. I removed the myForm.submit() since ASP.NET renders the page putting the WebForm_DoPostBackWithOptions() javascript in the button’s onclick right after it puts my pageSubmit()