ASP.net form and Javascript popup windows problem

T

tao lin

Hi, all

I am using VS2003 under WinXP. My WebApp has a WebForm which has a html
form has some search condition textbox, once the user fill in the condition
and click submit button. My app will stay in the same WebForm but open a
popup window in the browser to show the search results.

So I implement like this:

private void btnSubmit_Click(object sender, System.EventArgs e)
{
if (Page.IsValid)
{
Response.Write( "<script id='jsRpt'
language=javascript>window.open('"SearchResult.aspx"','new_Win');</script>")
;
}
}

It works fine for me. The only problem I get is: If the user click the
submit button more than one time, then click the IE browser 'back' button,
my WebForm will automatically open the previous popup window because IE
cache the html page and my popup window JavaScript is on the top of the html
page.
And I can not use <%@ OutputCache Location="None" %> because it will cause
my html form timeout.

So does anyone has some good suggestion that can handle a popup window with
html form within one aspx webform?

Cheers,

Tao
 
J

jasonkester

I would approach this from a different direction. On the page with the
search form, you could open your new window from an onClick event on
the search button. This will give you more consistent results.

<input type="submit" onclick="retarget()"
onserverclick="btnSubmit_Click" runat=server>

<script>
function retarget()
{
document.YourSearchForm.target="searchResults";
}
</script>

This way, you'll only ever end up with a single new window for your
search results.

Good Luck!
Jason

Expat Software Consulting Services
http://www.expatsoftware.com/
 
T

tao lin

Thank you for your suggestion, it works excellent.

I am new for asp.net and nerver use html control before, it looks like
sometimes html controls is better than the server control :)

Cheers,

Tao
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top