473,396 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1897
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.microsoft.com> wrote in
message news:E2**********************************@microsof t.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.getElementbyID("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.InsertData() . 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.microsoft.com> wrote in
message news:E2**********************************@microsof t.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 (hiddenflagtextbox.value ==1) {
InsertData();
}
}

On the CANCEL of the little box, I have set the field hiddenflagtextbox 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.getElementbyID("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.InsertData() . 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.microsoft.com> wrote in
message news:E2**********************************@microsof t.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.microsoft.com> wrote in
message news:9F**********************************@microsof t.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 (hiddenflagtextbox.value ==1) {
InsertData();
}
}

On the CANCEL of the little box, I have set the field hiddenflagtextbox 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.getElementbyID("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.InsertData() . 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.microsoft.com> wrote in
message news:E2**********************************@microsof t.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
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...
1
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...
6
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...
2
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...
6
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...
3
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...
0
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...
4
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...
3
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.