By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,644 Members | 2,423 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,644 IT Pros & Developers. It's quick & easy.

Submitting a form to a new window in ASP.NET

P: n/a
I have a form that I want to submit to a different page and in a new window.

I have done this using an HTML button and putting a target="_blank"
attribute in the FORM tag. This does give me the results, but I'm unable to
control the size and other properties of this new window.

If I try to takeout the runat=server attribute from the form element and
write a custom javascript function, then my other web controls in the form
(dropdown lists and others) start giving me errors.

What will be a neat and clean solution to do this... Any help?

Thanks in advance.
Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

There is no possiblility in ASP.NET 1.x to submit a form to another page
without playing some tricks (you should create your own page class that
inherit Page class). But you can do it fully on client side.
Add an HTML button:

<input type="button" name="submit" value="Submit a Form" onclick="return
submitNew()">

Suppose you have two textboxes on your form, named Text1 and Text2, then
your rendered to HTML form should look like:
<form id="frmMain">
Text1: <input type="text" id="Text1"><br />
Text2: <input type="text" id="Text2"><br />
<input type="button" name="submit" value="Submit a Form" onclick="return
submitNew()">
</form>

And add a simple JavaScript to your page:
<script>
function submitNew() {
window.open("http://somehost.com/SomePage.aspx?Text1=" +
frmMain.Text1.Value + "&Text2=" + frmMain.Text2.Value, "New Window",
"scrollbars=0, height=400, width=600, left=20, top=20");
}
</script>

Gaidar

"mavrick101" <ma********@discussions.microsoft.com> wrote in message
news:19**********************************@microsof t.com...
I have a form that I want to submit to a different page and in a new
window.

I have done this using an HTML button and putting a target="_blank"
attribute in the FORM tag. This does give me the results, but I'm unable
to
control the size and other properties of this new window.

If I try to takeout the runat=server attribute from the form element and
write a custom javascript function, then my other web controls in the form
(dropdown lists and others) start giving me errors.

What will be a neat and clean solution to do this... Any help?

Thanks in advance.

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.