Link to home
Start Free TrialLog in
Avatar of newbreedcc
newbreedcc

asked on

Navigation -> Open New Window Dilemma... asp.net

In my asp.net app, I am trying to open a new window from a button.click event.  This new window (window#2) should be opened from my "search" webform (window#1), where the new window contains the search results.


Everytime the user updates the search criteria in window#1 and click search button I want to update window#2 with the results. (preferable without opening a window#3, rather refresh window#2 if window#2 (results page) was already open.)  The way I send my search criteria to window#2 is via a session variable (sql WHERE clause)


I have tried a couple different approaches, however, none of them seems to work 100%, I need few pointers.


Here's what I tried:

1. Simplest solution seems to change a setting on my search webform to point to results page: <base target="resultspage.aspx(window#2)">
The above worked fine, however I have more than one button on my search page which performs postbacks, hence everytime a postback is performed (from a button other than search button) it would push the html from the server to window#2, I only want it to push html to window#2 when I click on the search button.  Thus is there a way that I can dynamically change the target of my form server side?


2. I added OnClick js script serverside, where I would build-up my javascript function (or I just add button1.attributes.add("OnClick",.... ), when user clicks the search button first time it works fine, after that it opens a new window everytime and does not update my session variable (new WHERE clause).  Reason being that once the button1.attibute is added it doesn't seem to go to the server side code (where I set my new session variable) it just opens the new windown right away without using the updated session variable, hence I would see the same search results when I change my search criteria.

Any help would be appreciated.
Thanks!

Avatar of puranik_p
puranik_p
Flag of India image

What you can do is instead of using <base target="resultspage.aspx(window#2)">, use jacascript with window.child.

For each of the buttons which goes for search, check..
if (window.child == null)
{
// open a new window
}
else
{
//use the same window.
//example..window.child.location.href = "searchresult.aspx"
}
Avatar of newbreedcc
newbreedcc

ASKER

I went with a different approach in the end.

Please close and refund.
newbreedcc, can you post the approach that you used.
It might be helpful to others.
I recommend:
if newbreedcc returns back with solution, PAQ/Refund
else accept Pura
I open a new window with script, and everytime the same link is clicked it would not open another new window, rather detect that window is already open and refresh.  I created a menu bar that acts as a launch pad to open menu items, here's how.

btnItemMstr.Attributes.Add("OnClick", "newWindowItemMstr = window.open('itemMstr_AdvSearch.aspx','newWindowItemMstr', 'width=' + (screen.availWidth - 165) + ',height=' + (screen.availHeight - 50) + ',left=150,top=0,status=yes,toolbar=no,menubar=no,scrollbars=yes,resizable=yes'); newWindowItemMstr.focus();")

ASKER CERTIFIED SOLUTION
Avatar of Lunchy
Lunchy
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial