473,549 Members | 2,781 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Close a window then cause some server code to run if user hits can

I have this scenario (simplified)

function addnewdata () {
check for partial match already in db for information entered by user
if (partialmatch succeeds) {
open new window aspx page (using javascript) with a datagrid of these
partial match records (by doing a sqlcommand using some query string values
taken from opener data entered)
***
}
else
{
no partial matches already so do an insert of new data entered
}
}

at the point I have put *** - this is a new little window - it shows some
records. The user may hit SELECT for a given record. If they do, I have some
code which runs, inserts into the db, refreshes the opener screen and the
page is refreshed with this record which works fine. If they hit CANCEL they
have decided that they do not want to use a partial record and want to
proceed with the data entered. My question: If they hit cancel, how do I
then get into the ELSE clause of this function ??? Currently my cancel just
has javascript self.close in it. The window dissapears and the original data
entered is sitting there in the opener page, but i cannot figure out how to
say, ok now go and insert this data ! Do I have to use return false;
somewhere? not sure where. I thought about creating a new function to insert
a data if the user has hit cancel but dont know how to test that the user has
hit cancel in this window then run some server code. Real head block :o( any
help appreciated. many thanks. Lou.
Nov 19 '05 #1
4 1910
Louise,

I see two options.
(a) when they hit cancel in the popup why not have the popup postback and
process the insert in the cancel's event, then close the popup
(b) have the cancel button a pure javascript which does self.close() but
before doing so makes the parent page postback and have it process the new
record.

I prefer the first approach because it's pretty simple server-side postback
(click button, in event do processing and then output self.close()). The
second approach forces you to use javascript to cause postback to occur,
which is doable..but not as clean.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"louise raisbeck" <lo************ @discussions.mi crosoft.com> wrote in
message news:E2******** *************** ***********@mic rosoft.com...
I have this scenario (simplified)

function addnewdata () {
check for partial match already in db for information entered by user
if (partialmatch succeeds) {
open new window aspx page (using javascript) with a datagrid of these
partial match records (by doing a sqlcommand using some query string values taken from opener data entered)
***
}
else
{
no partial matches already so do an insert of new data entered
}
}

at the point I have put *** - this is a new little window - it shows some
records. The user may hit SELECT for a given record. If they do, I have some code which runs, inserts into the db, refreshes the opener screen and the
page is refreshed with this record which works fine. If they hit CANCEL they have decided that they do not want to use a partial record and want to
proceed with the data entered. My question: If they hit cancel, how do I
then get into the ELSE clause of this function ??? Currently my cancel just has javascript self.close in it. The window dissapears and the original data entered is sitting there in the opener page, but i cannot figure out how to say, ok now go and insert this data ! Do I have to use return false;
somewhere? not sure where. I thought about creating a new function to insert a data if the user has hit cancel but dont know how to test that the user has hit cancel in this window then run some server code. Real head block :o( any help appreciated. many thanks. Lou.

Nov 19 '05 #2
Thank you. I cannot do A (dont think) because the Insert statement server
code resides on the opener page as does all the text boxes/drop downs with
all the user's entry in it, ready to be posted (because they've hit cancel on
the 'do you want to choose one of these instead' window).

The only thing i could do which is similar to your solution A would be to
pretend I am on the opener page and grab all of the user entry from all the
controls (using opener.getEleme ntbyID("blah") 20 times and Insert here while
still in the little window, then close that window and reload the opener.
nasty though.

i have tried doing postback on the close of the little window, but i end up
in a loop of it finding partial matches! I somehow need to escape the fact
this, so act as if there were no partial matches in the first place. Since I
posted I put the insert statement into a function. called InsertData(). Can i
somehow call opener.InsertDa ta() . This is exactly what I need to do, but i
cannot because opener is a javascript object (to mean parent page) and
InsertData() is a server function. so near but so far !

"Karl Seguin" wrote:
Louise,

I see two options.
(a) when they hit cancel in the popup why not have the popup postback and
process the insert in the cancel's event, then close the popup
(b) have the cancel button a pure javascript which does self.close() but
before doing so makes the parent page postback and have it process the new
record.

I prefer the first approach because it's pretty simple server-side postback
(click button, in event do processing and then output self.close()). The
second approach forces you to use javascript to cause postback to occur,
which is doable..but not as clean.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"louise raisbeck" <lo************ @discussions.mi crosoft.com> wrote in
message news:E2******** *************** ***********@mic rosoft.com...
I have this scenario (simplified)

function addnewdata () {
check for partial match already in db for information entered by user
if (partialmatch succeeds) {
open new window aspx page (using javascript) with a datagrid of these
partial match records (by doing a sqlcommand using some query string

values
taken from opener data entered)
***
}
else
{
no partial matches already so do an insert of new data entered
}
}

at the point I have put *** - this is a new little window - it shows some
records. The user may hit SELECT for a given record. If they do, I have

some
code which runs, inserts into the db, refreshes the opener screen and the
page is refreshed with this record which works fine. If they hit CANCEL

they
have decided that they do not want to use a partial record and want to
proceed with the data entered. My question: If they hit cancel, how do I
then get into the ELSE clause of this function ??? Currently my cancel

just
has javascript self.close in it. The window dissapears and the original

data
entered is sitting there in the opener page, but i cannot figure out how

to
say, ok now go and insert this data ! Do I have to use return false;
somewhere? not sure where. I thought about creating a new function to

insert
a data if the user has hit cancel but dont know how to test that the user

has
hit cancel in this window then run some server code. Real head block :o(

any
help appreciated. many thanks. Lou.


Nov 19 '05 #3
Karl. I think I have fixed it. In my Page_Load of the opener i have put an
else in the if (!ispostback) {
blah
}
else {
//we are in postback
if (hiddenflagtext box.value ==1) {
InsertData();
}
}

On the CANCEL of the little box, I have set the field hiddenflagtextb ox on
the opener page to 1, then called opener.document .forms[0].submit() then
window.close(). So because i've said do a submit on the opener it runs the
ELSE clause above, inserts the data the user entered originally and reloads.
I cannot believe it worked, it was a complete guess !

"louise raisbeck" wrote:
Thank you. I cannot do A (dont think) because the Insert statement server
code resides on the opener page as does all the text boxes/drop downs with
all the user's entry in it, ready to be posted (because they've hit cancel on
the 'do you want to choose one of these instead' window).

The only thing i could do which is similar to your solution A would be to
pretend I am on the opener page and grab all of the user entry from all the
controls (using opener.getEleme ntbyID("blah") 20 times and Insert here while
still in the little window, then close that window and reload the opener.
nasty though.

i have tried doing postback on the close of the little window, but i end up
in a loop of it finding partial matches! I somehow need to escape the fact
this, so act as if there were no partial matches in the first place. Since I
posted I put the insert statement into a function. called InsertData(). Can i
somehow call opener.InsertDa ta() . This is exactly what I need to do, but i
cannot because opener is a javascript object (to mean parent page) and
InsertData() is a server function. so near but so far !

"Karl Seguin" wrote:
Louise,

I see two options.
(a) when they hit cancel in the popup why not have the popup postback and
process the insert in the cancel's event, then close the popup
(b) have the cancel button a pure javascript which does self.close() but
before doing so makes the parent page postback and have it process the new
record.

I prefer the first approach because it's pretty simple server-side postback
(click button, in event do processing and then output self.close()). The
second approach forces you to use javascript to cause postback to occur,
which is doable..but not as clean.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"louise raisbeck" <lo************ @discussions.mi crosoft.com> wrote in
message news:E2******** *************** ***********@mic rosoft.com...
I have this scenario (simplified)

function addnewdata () {
check for partial match already in db for information entered by user
if (partialmatch succeeds) {
open new window aspx page (using javascript) with a datagrid of these
partial match records (by doing a sqlcommand using some query string

values
taken from opener data entered)
***
}
else
{
no partial matches already so do an insert of new data entered
}
}

at the point I have put *** - this is a new little window - it shows some
records. The user may hit SELECT for a given record. If they do, I have

some
code which runs, inserts into the db, refreshes the opener screen and the
page is refreshed with this record which works fine. If they hit CANCEL

they
have decided that they do not want to use a partial record and want to
proceed with the data entered. My question: If they hit cancel, how do I
then get into the ELSE clause of this function ??? Currently my cancel

just
has javascript self.close in it. The window dissapears and the original

data
entered is sitting there in the opener page, but i cannot figure out how

to
say, ok now go and insert this data ! Do I have to use return false;
somewhere? not sure where. I thought about creating a new function to

insert
a data if the user has hit cancel but dont know how to test that the user

has
hit cancel in this window then run some server code. Real head block :o(

any
help appreciated. many thanks. Lou.


Nov 19 '05 #4
Louise,
Yes, having the popup set a value which you can read from Request.Form or
how you are doing it is the best way to separate between the two postbacks.

Glad i was able to help a bit.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"louise raisbeck" <lo************ @discussions.mi crosoft.com> wrote in
message news:9F******** *************** ***********@mic rosoft.com...
Karl. I think I have fixed it. In my Page_Load of the opener i have put an
else in the if (!ispostback) {
blah
}
else {
//we are in postback
if (hiddenflagtext box.value ==1) {
InsertData();
}
}

On the CANCEL of the little box, I have set the field hiddenflagtextb ox on
the opener page to 1, then called opener.document .forms[0].submit() then
window.close(). So because i've said do a submit on the opener it runs the
ELSE clause above, inserts the data the user entered originally and reloads. I cannot believe it worked, it was a complete guess !

"louise raisbeck" wrote:
Thank you. I cannot do A (dont think) because the Insert statement server code resides on the opener page as does all the text boxes/drop downs with all the user's entry in it, ready to be posted (because they've hit cancel on the 'do you want to choose one of these instead' window).

The only thing i could do which is similar to your solution A would be to pretend I am on the opener page and grab all of the user entry from all the controls (using opener.getEleme ntbyID("blah") 20 times and Insert here while still in the little window, then close that window and reload the opener. nasty though.

i have tried doing postback on the close of the little window, but i end up in a loop of it finding partial matches! I somehow need to escape the fact this, so act as if there were no partial matches in the first place. Since I posted I put the insert statement into a function. called InsertData(). Can i somehow call opener.InsertDa ta() . This is exactly what I need to do, but i cannot because opener is a javascript object (to mean parent page) and
InsertData() is a server function. so near but so far !

"Karl Seguin" wrote:
Louise,

I see two options.
(a) when they hit cancel in the popup why not have the popup postback and process the insert in the cancel's event, then close the popup
(b) have the cancel button a pure javascript which does self.close() but before doing so makes the parent page postback and have it process the new record.

I prefer the first approach because it's pretty simple server-side postback (click button, in event do processing and then output self.close()). The second approach forces you to use javascript to cause postback to occur, which is doable..but not as clean.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"louise raisbeck" <lo************ @discussions.mi crosoft.com> wrote in
message news:E2******** *************** ***********@mic rosoft.com...
> I have this scenario (simplified)
>
> function addnewdata () {
> check for partial match already in db for information entered by user > if (partialmatch succeeds) {
> open new window aspx page (using javascript) with a datagrid of these > partial match records (by doing a sqlcommand using some query string
values
> taken from opener data entered)
> ***
> }
> else
> {
> no partial matches already so do an insert of new data entered
> }
> }
>
> at the point I have put *** - this is a new little window - it shows some > records. The user may hit SELECT for a given record. If they do, I have some
> code which runs, inserts into the db, refreshes the opener screen and the > page is refreshed with this record which works fine. If they hit CANCEL they
> have decided that they do not want to use a partial record and want to > proceed with the data entered. My question: If they hit cancel, how do I > then get into the ELSE clause of this function ??? Currently my cancel just
> has javascript self.close in it. The window dissapears and the original data
> entered is sitting there in the opener page, but i cannot figure out how to
> say, ok now go and insert this data ! Do I have to use return false;
> somewhere? not sure where. I thought about creating a new function to insert
> a data if the user has hit cancel but dont know how to test that the user has
> hit cancel in this window then run some server code. Real head block :o( any
> help appreciated. many thanks. Lou.

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
9300
by: Simon Fletcher | last post by:
Hello there, I need a "Close Window" script ( onLoad.Close.Window() ), however i need the script so it don't come up with this annoying window: "This window is trying to close" window. Is there a script to stop this happening and close the window anyway? Simon Fletcher
1
3440
by: Ivan Sutton | last post by:
Hi, I'm quite new to Java: I installed a script which opened a window in a predefined format. It works fine! I want to know if it is possible to close that screen with java. (however, the code should be in the childpage) Thank you,
6
8509
by: chon | last post by:
I have an ASP page that is sent a file location as a parameter. It opens this file, loads the ADODB.Stream object and does a binary write to the page forcing the download dialog to appear. This all works fine. If the user selects "Open" or "Cancel", the window closes, which is the desired behavior. If they select "Save", the location dialog...
2
23258
by: BWGames | last post by:
Hi, I'm looking for a way to have a message box pop up as a page is loaded, then, when the user clicks OK on the message box, for the window to close. It will be a popup window, so there won't be any "This webpage is trying to close this window" errors... Anyone help me out?
6
5664
by: clequieu | last post by:
I have created a form. Within the form is a button to close the window on click and to validate as well. The close window works when it is a stand alone, but it does not work when it is embedded with the other code. Here is the code I am currently using: <p><font face="Trebuchet MS"> <input type="submit" value="Send" name="B1"...
3
12283
by: jayuya | last post by:
I have a simple page that I will like to display while i am processing the user request in the server. The page only has a label saying "Please Wait..." My objective is to show this window while the code executes in the server but I can not close it after i am done... below is a sample code.... thanks in advance... jayuya
0
945
by: Kenneth Keeley | last post by:
Hi, If I create a first page that displays a second window while something is happening on the first page (ie A file is uploading, or a database update), How do I get the first page to close the second window once the first page as finished doing the things it needed to do. I don't want to refresh the second page to get it to close. I have...
4
5073
by: DM | last post by:
Is there any way, using a server control, to execute a routine (say, add record to database) and then close the browser window. I'm having a difficult time doing this using a master\detail model where dialog apsx page is opened when datagrid item on master page is clicked. Would like to be able to have detail open in the html dialog where...
3
1788
by: Marcel Balcarek | last post by:
I have a sub-window. When I click 'OK' I want to: post back to to my server code, persist some data and close the sub-window. I don't know how to close the subwindow in server code. Marcel
0
7520
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7450
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7720
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7957
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7809
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5088
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.