Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > window.top.location.href

Reply
Thread Tools

window.top.location.href

 
 
Scott
Guest
Posts: n/a
 
      12-22-2003
I'm new to ASP, but I've been programming in VB for
several years, and I'm having a few issues with this ASP
enhancement I'm working on. I've found ASP to be a lot
different than what I'm use to in VB.

I've created an ASP interface where a user can select an
email group that populates a listbox with those email
addresses. If a user sees an email in that list that they
do not want then they can remove it by clinking the Delete
button and conversely do the same for Adding emails. I'm
trying to accomplish this by creating a popup window when
a use clicks the "Add or Delete" button. In this popup
ASP page the user can then Add or Delete additional email
(s) addresses depending on the button they chose. After
they have made their changes they can click the submit
button to update the previous page.

How do I get the ASP page to popup?
Right now, when I use
onclick="window.top.location.href='Add_Emails.asp' " my ASP
page loads itself in the current browser window instead of
it's own.

How do I get the data from the popup ASP page to post the
changes in my listbox on the previous ASP page?
For example, the email group I chose has John, Betty, and
Joe, but I want Maggie added to the list. In theory my
new list should show John, Betty, Joe, and Maggie.
 
Reply With Quote
 
 
 
 
Foo Man Chew
Guest
Posts: n/a
 
      12-22-2003
> How do I get the ASP page to popup?

Look at window.open() ... please see a JavaScript newsgroup.

> How do I get the data from the popup ASP page to post the
> changes in my listbox on the previous ASP page?


You'll have to say
window.opener.location.href='somepage.asp?add=foo@ man.chew&delete=bob@franks
..com';

Then rebuild the SELECT box based on request.querystring accordingly.


 
Reply With Quote
 
 
 
 
Roland Hall
Guest
Posts: n/a
 
      12-23-2003
"Scott" wrote:
> I'm new to ASP, but I've been programming in VB for
> several years, and I'm having a few issues with this ASP
> enhancement I'm working on. I've found ASP to be a lot
> different than what I'm use to in VB.
>
> I've created an ASP interface where a user can select an
> email group that populates a listbox with those email
> addresses. If a user sees an email in that list that they
> do not want then they can remove it by clinking the Delete
> button and conversely do the same for Adding emails. I'm
> trying to accomplish this by creating a popup window when
> a use clicks the "Add or Delete" button. In this popup
> ASP page the user can then Add or Delete additional email
> (s) addresses depending on the button they chose. After
> they have made their changes they can click the submit
> button to update the previous page.
>
> How do I get the ASP page to popup?
> Right now, when I use
> onclick="window.top.location.href='Add_Emails.asp' " my ASP
> page loads itself in the current browser window instead of
> it's own.
>
> How do I get the data from the popup ASP page to post the
> changes in my listbox on the previous ASP page?
> For example, the email group I chose has John, Betty, and
> Joe, but I want Maggie added to the list. In theory my
> new list should show John, Betty, Joe, and Maggie.


Where are the email addresses stored now? Are they in a database or in a
document or hard coded into the page?

--
Roland

This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.


 
Reply With Quote
 
Scott
Guest
Posts: n/a
 
      12-23-2003
They are stored in a SQL Database.

I make a call out to a Stored Procedure that returns the
entire list of emails base on the group selected from a
dropdown box, and then populates the listbox with all the
email addresses. There is nothing hard-code in the
WebPages I'm doing.

If this helps, I using a standard button instead of a
submit button, when adding or deleting emails from the
listbox. When the new ASP page is launched after clicking
one of these two buttons, it has just a textbox and a
SUBMIT button on it.

My intention is to use this same ASP page for both adding
and deleting emails from the listbox, unless someone has a
better suggestion. As I stated before, I've done more VB
programming than ASP programming, and I'd rather tag the
emails and click delete to remove them than to bring up an
ASP page to do it, but I not sure how to do it in ASP.
Adding emails this way is fine.



>-----Original Message-----
>"Scott" wrote:
>> I'm new to ASP, but I've been programming in VB for
>> several years, and I'm having a few issues with this ASP
>> enhancement I'm working on. I've found ASP to be a lot
>> different than what I'm use to in VB.
>>
>> I've created an ASP interface where a user can select an
>> email group that populates a listbox with those email
>> addresses. If a user sees an email in that list that

they
>> do not want then they can remove it by clinking the

Delete
>> button and conversely do the same for Adding emails.

I'm
>> trying to accomplish this by creating a popup window

when
>> a use clicks the "Add or Delete" button. In this popup
>> ASP page the user can then Add or Delete additional

email
>> (s) addresses depending on the button they chose. After
>> they have made their changes they can click the submit
>> button to update the previous page.
>>
>> How do I get the ASP page to popup?
>> Right now, when I use
>> onclick="window.top.location.href='Add_Emails.asp' " my

ASP
>> page loads itself in the current browser window instead

of
>> it's own.
>>
>> How do I get the data from the popup ASP page to post

the
>> changes in my listbox on the previous ASP page?
>> For example, the email group I chose has John, Betty,

and
>> Joe, but I want Maggie added to the list. In theory my
>> new list should show John, Betty, Joe, and Maggie.

>
>Where are the email addresses stored now? Are they in a

database or in a
>document or hard coded into the page?
>
>--
>Roland
>
>This information is distributed in the hope that it will

be useful, but
>without any warranty; without even the implied warranty

of merchantability
>or fitness for a particular purpose.
>
>
>.
>

 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      12-24-2003
"Scott" wrote:
> If this helps, I using a standard button instead of a
> submit button, when adding or deleting emails from the
> listbox. When the new ASP page is launched after clicking
> one of these two buttons, it has just a textbox and a
> SUBMIT button on it.

If it only has a text box and submit, how do you identify the person to
delete?

> My intention is to use this same ASP page for both adding
> and deleting emails from the listbox, unless someone has a
> better suggestion.


Using two pages is probably easier but using one means you need to determine
if your method is POST or GET and then you check for input to the page
before you build the page.

> As I stated before, I've done more VB
> programming than ASP programming,


It was weird for me when I started using ASP. VB.NET would be easier for
you. The best advice I think anyone can give you re: ASP in the beginning
is that ASP processes ONLY ASP code and passes everything else to the
client, including processed results. When you surf to an ASP page and view
the source, you're seeing the results and the ASP engine is done.

> and I'd rather tag the
> emails and click delete to remove them than to bring up an
> ASP page to do it,

You could do it that way too. Do you want to delete one at a time or
multiple? When do you want to update the database?

> but I not sure how to do it in ASP.
> Adding emails this way is fine.

Yes, adding is always easier.

What I get from your posts is: (I will number these and reference them by
number in my response)
1. You have a list box where you select a group. You do not mention a
submit key so I assume this is an onChange event. Doesn't matter either
way.
2. This makes a call to a SP which dynamically builds another list box with
the email addresses of the group selected from the other list box.
3. One of two buttons is then clicked [add/delete] and a popup window which
contains a text box and a submit button is used to add/delete email
addresses for this particular group only.
4. The 'opener' window should reflect, assumingly the email address list,
the result of an additional email address or the elimination of one.

1. Since you are going to definitely add/delete records, I would populate
the groups and addresses into arrays when the page loads. This is one trip
to the server and I don't have to call it in the middle of my process,
however, one might argue it would be unnecessary if the task was aborted
before changes were made. Of course if you had 100 groups and 1000 users
per group, I'd probably rethink this. When the appropriate group was
selected, I would populate the email address list box with the appropriate
values from the array. This is faster than a trip to the server.

2. Here is where I differ on the add/delete processes being the same.
Unless you need to get a list, which is why I would populate upon entry to
the page, I would not select a group and then get a list and then click to
add an address. I would show a list and then you click add and on the add,
select the group and add the email address in one step, submit and update
the opener window, however, I think it would be better in a frame.

3. I think to delete an email address, you don't need to popup a window
except to confirm a deletion. Once you confirm, then you make a trip to the
server and update the database. If posting to the same page, then this
would be handled upon entry. You would pass the information either in the
header [method=post] or on the URL [method=get], it really doesn't matter.
I also pass a flag which identifies the task, ex.
/asp/somefile.asp?address=(E-Mail Removed)&task=delete .

4. If you use a popup to add, then you assign that window a handle.
Ex. var w=window.open('',"addEmail",features);

Then you reference the handle to build the page. Loading a preset page is
easier than building it on the fly but it is a trip to the drive. Probably
not a deal killer considering the size. Now, you can either update the
opener window and then close the popup but you still need to process the
data and send it to the server. You could do that in the popup but why
duplicate code for server access? I would call to process the opener window
with the results and have it check as part of it's opening routine if the
popup is open and close it, update the server and then rebuild the list. If
you want to keep the group selected, then you need to pass another variable
identifying the group.
/asp/somefile.asp?group=corporate&address=jerry@mcquire .com&task=delete.

As far as your popup not working, I have a simple popup routine I use.
<!--
// Options:
// toolbar (yes,no)
// location (yes,no)
// directories (yes,no)
// status (yes,no)
// menubar (yes,no)
// scrollbars (yes,no)
// resizable (yes,no)
// copyhistory (yes,no)
// width=size
// height=size
var winHandle='';
var winname='';
function popup(url, winname) {
var features = "menubar=no, width=200, height=200";
w = window.open(url,winname,features);
if(!w.opener) w.opener = self;
// other code goes here
}
//-->

If you want multiple windows from a single page that need different
attributes, then I use:
<!--
// Author: Roland Hall
// Copyright (c) 2003 - Dangerously, Inc.
// Free for non-commercial use
// All rights reserved world wide
// Options:
// toolbar (yes,no)
// location (yes,no)
// directories (yes,no)
// status (yes,no)
// menubar (yes,no)
// scrollbars (yes,no)
// resizable (yes,no)
// copyhistory (yes,no)
// width=size
// height=size
var features, w, h;
function popupwin(url, winname, features, w, h) {
// Use the line below during debugging
//alert('url: ' + url + '\r\nwinname: ' + winname + '\r\nfeatures: ' +
features + '\r\nw : ' + w + '\r\nh : ' + h);
if(!w && !h) {
w=600; // default width
h=600; // default height
}
if(!features) {
features = 'width=' + w + ', height=' + h;
} else {
features += ', width=' + w + ', height=' + h;
}
// Use the line below during debugging
//alert('w = ' + w + '\nh = ' + h + '\nfeatures = ' + features);
popwin = window.open(url,winname,features);
}
//-->

--
Roland

This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.


 
Reply With Quote
 
Scott
Guest
Posts: n/a
 
      12-24-2003
Thanks Roland. I would have to say that you have all the
details correct for the most part with some exceptions
that I did not include in my previous post.

1. On ASP load, I dynamically load a dropdown box with all
Email groups. You are correct, I use the onChange event
to dynamically load a listbox with the Email Addresses.
If the user sees an email that they do or don't want then
they can add/remove it by pressing the ADD or DELETE
button.

2. You are correct, both are built using SP's.

3. You are correct. Here's what the code looks like.
<TR>
<TH align="middle" valign="top" nowrap>
<INPUT type="button" value="Add" id=Add name=Add
style="WIDTH: 50px; HEIGHT: 20px" onclick="window.open
('UpdateEmails.asp',null,'toolbar=0,scrollbars=0,
resizable=1,
location=0,height=100,width=440,menubar=0,left=300 ,top=250'
)">
</TH>
</TR>
<TR>
<TH align="middle" valign="top" nowrap>
<INPUT type="button" value="Delete" id=Delete name=Delete
style="WIDTH: 50px; HEIGHT: 20px" onclick="window.open
('UpdateEmails.asp',null,'toolbar=0,scrollbars=0,
resizable=1, location=0,
height=100,width=440,menubar=0,left=300,top=250')" >
</TH>
</TR>

At the moment, to add an email address you would type it
in and presses submit.

The same thing is what I considered for the delete
process, but I've been rethinking that. I would prefer to
do tag each email using the CTLR key then press the delete
key, but I'm not sure how to do that in ASP.

4. I'm ONLY updating the LISTBOX with additions/deletions
of emails. No DB updates are being done. There is a
separate profile's ASP page for that already.

5. Once all emails are selected the user can press the
email button on the main WebPages. To me, it's a modified
version of email software using the NotesMail object. I
think it would have been easier to develop something in
Lotus Notes rather than ASP, but I don't think anyone here
knows how and they wanted it done this way.

6. You had suggested using a frame instead of a popup.
How do I do that? What are the advantages of a frame
opposed to popping up a new ASP? Would you recommend
having the frame open onload or when the user click
add/delete, then close after their selections? I
personally don't like popup, but there are some cases in
which they are useful.


>-----Original Message-----
>"Scott" wrote:
>> If this helps, I using a standard button instead of a
>> submit button, when adding or deleting emails from the
>> listbox. When the new ASP page is launched after

clicking
>> one of these two buttons, it has just a textbox and a
>> SUBMIT button on it.

>If it only has a text box and submit, how do you identify

the person to
>delete?
>
>> My intention is to use this same ASP page for both

adding
>> and deleting emails from the listbox, unless someone

has a
>> better suggestion.

>
>Using two pages is probably easier but using one means

you need to determine
>if your method is POST or GET and then you check for

input to the page
>before you build the page.
>
>> As I stated before, I've done more VB
>> programming than ASP programming,

>
>It was weird for me when I started using ASP. VB.NET

would be easier for
>you. The best advice I think anyone can give you re: ASP

in the beginning
>is that ASP processes ONLY ASP code and passes everything

else to the
>client, including processed results. When you surf to an

ASP page and view
>the source, you're seeing the results and the ASP engine

is done.
>
>> and I'd rather tag the
>> emails and click delete to remove them than to bring up

an
>> ASP page to do it,

>You could do it that way too. Do you want to delete one

at a time or
>multiple? When do you want to update the database?
>
>> but I not sure how to do it in ASP.
>> Adding emails this way is fine.

>Yes, adding is always easier.
>
>What I get from your posts is: (I will number these and

reference them by
>number in my response)
>1. You have a list box where you select a group. You do

not mention a
>submit key so I assume this is an onChange event.

Doesn't matter either
>way.
>2. This makes a call to a SP which dynamically builds

another list box with
>the email addresses of the group selected from the other

list box.
>3. One of two buttons is then clicked [add/delete] and a

popup window which
>contains a text box and a submit button is used to

add/delete email
>addresses for this particular group only.
>4. The 'opener' window should reflect, assumingly the

email address list,
>the result of an additional email address or the

elimination of one.
>
>1. Since you are going to definitely add/delete records,

I would populate
>the groups and addresses into arrays when the page

loads. This is one trip
>to the server and I don't have to call it in the middle

of my process,
>however, one might argue it would be unnecessary if the

task was aborted
>before changes were made. Of course if you had 100

groups and 1000 users
>per group, I'd probably rethink this. When the

appropriate group was
>selected, I would populate the email address list box

with the appropriate
>values from the array. This is faster than a trip to the

server.
>
>2. Here is where I differ on the add/delete processes

being the same.
>Unless you need to get a list, which is why I would

populate upon entry to
>the page, I would not select a group and then get a list

and then click to
>add an address. I would show a list and then you click

add and on the add,
>select the group and add the email address in one step,

submit and update
>the opener window, however, I think it would be better in

a frame.
>
>3. I think to delete an email address, you don't need to

popup a window
>except to confirm a deletion. Once you confirm, then you

make a trip to the
>server and update the database. If posting to the same

page, then this
>would be handled upon entry. You would pass the

information either in the
>header [method=post] or on the URL [method=get], it

really doesn't matter.
>I also pass a flag which identifies the task, ex.
>/asp/somefile.asp?address=(E-Mail Removed)&task=delete .
>
>4. If you use a popup to add, then you assign that window

a handle.
>Ex. var w=window.open('',"addEmail",features);
>
>Then you reference the handle to build the page. Loading

a preset page is
>easier than building it on the fly but it is a trip to

the drive. Probably
>not a deal killer considering the size. Now, you can

either update the
>opener window and then close the popup but you still need

to process the
>data and send it to the server. You could do that in the

popup but why
>duplicate code for server access? I would call to

process the opener window
>with the results and have it check as part of it's

opening routine if the
>popup is open and close it, update the server and then

rebuild the list. If
>you want to keep the group selected, then you need to

pass another variable
>identifying the group.
>/asp/somefile.asp?

group=corporate&address=(E-Mail Removed)&task=del ete.
>
>As far as your popup not working, I have a simple popup

routine I use.
><!--
>// Options:
>// toolbar (yes,no)
>// location (yes,no)
>// directories (yes,no)
>// status (yes,no)
>// menubar (yes,no)
>// scrollbars (yes,no)
>// resizable (yes,no)
>// copyhistory (yes,no)
>// width=size
>// height=size
>var winHandle='';
>var winname='';
>function popup(url, winname) {
>var features = "menubar=no, width=200, height=200";
>w = window.open(url,winname,features);
>if(!w.opener) w.opener = self;
>// other code goes here
>}
>//-->
>
>If you want multiple windows from a single page that need

different
>attributes, then I use:
><!--
>// Author: Roland Hall
>// Copyright (c) 2003 - Dangerously, Inc.
>// Free for non-commercial use
>// All rights reserved world wide
>// Options:
>// toolbar (yes,no)
>// location (yes,no)
>// directories (yes,no)
>// status (yes,no)
>// menubar (yes,no)
>// scrollbars (yes,no)
>// resizable (yes,no)
>// copyhistory (yes,no)
>// width=size
>// height=size
>var features, w, h;
>function popupwin(url, winname, features, w, h) {
>// Use the line below during debugging
>//alert('url: ' + url + '\r\nwinname: ' + winname

+ '\r\nfeatures: ' +
>features + '\r\nw : ' + w + '\r\nh : ' + h);
> if(!w && !h) {
> w=600; // default width
> h=600; // default height
> }
> if(!features) {
> features = 'width=' + w + ', height=' + h;
> } else {
> features += ', width=' + w + ', height=' + h;
> }
>// Use the line below during debugging
>//alert('w = ' + w + '\nh = ' + h + '\nfeatures = ' +

features);
> popwin = window.open(url,winname,features);
>}
>//-->
>
>--
>Roland
>
>This information is distributed in the hope that it will

be useful, but
>without any warranty; without even the implied warranty

of merchantability
>or fitness for a particular purpose.
>
>
>.
>

 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      12-28-2003
"Scott" wrote:
> Thanks Roland.

You're welcome. (O:=

> 3. You are correct. Here's what the code looks like.
> <TR>
> <TH align="middle" valign="top" nowrap>
> <INPUT type="button" value="Add" id=Add name=Add
> style="WIDTH: 50px; HEIGHT: 20px" onclick="window.open
> ('UpdateEmails.asp',null,'toolbar=0,scrollbars=0,
> resizable=1,
> location=0,height=100,width=440,menubar=0,left=300 ,top=250'
> )">
> </TH>
> </TR>
> <TR>
> <TH align="middle" valign="top" nowrap>
> <INPUT type="button" value="Delete" id=Delete name=Delete
> style="WIDTH: 50px; HEIGHT: 20px" onclick="window.open
> ('UpdateEmails.asp',null,'toolbar=0,scrollbars=0,
> resizable=1, location=0,
> height=100,width=440,menubar=0,left=300,top=250')" >
> </TH>
> </TR>
>
> At the moment, to add an email address you would type it
> in and presses submit.
>
> The same thing is what I considered for the delete
> process, but I've been rethinking that. I would prefer to
> do tag each email using the CTLR key then press the delete
> key, but I'm not sure how to do that in ASP.

I'm not sure why you're popping up a window after the choice is chosen to
delete. If you already have a list, you could just tag and delete from
there and possibly add a confirmation for the delete which could popup. To
add, yes, popping up a window or exposing a hidden area to accept input
would work.

> 4. I'm ONLY updating the LISTBOX with additions/deletions
> of emails. No DB updates are being done. There is a
> separate profile's ASP page for that already.

So, when you update, the list updates in the list array and when you submit
you do what, rewrite the list, only modify the ones that have changed? How
do you verify which ones need to be updated?

> 5. Once all emails are selected the user can press the
> email button on the main WebPages. To me, it's a modified
> version of email software using the NotesMail object. I
> think it would have been easier to develop something in
> Lotus Notes rather than ASP, but I don't think anyone here
> knows how and they wanted it done this way.

Are you saying a lot of email addresses are tagged (selected) and then when
you press this email button that a message gets sent to these addresses?

> 6. You had suggested using a frame instead of a popup.
> How do I do that?

If you were using a frame, you would set your main page as a frameset. Put
your controls in one frame, put your existing data in another frame. Click
on a control to perform a function and update the data, with the results, in
the other frame.

> What are the advantages of a frame
> opposed to popping up a new ASP?

Everything stays in the same window but other than that I can't think of
any. Dealing with a frame is similar to dealing with popup windows since
you have to specify your target. You name the frames in your frameset and
then call for them by name.

> Would you recommend
> having the frame open onload or when the user click
> add/delete, then close after their selections?

Seeing that you're only working with one add and one delete routine and then
a button to email with two list boxes, I'd probably do it all on one page
and just use hidden controls. However, any of these should be as easy as
the next. Hidden controls, frameset, popup window...

> I
> personally don't like popup, but there are some cases in
> which they are useful.


I usually only use popup windows for data entry except for alert
notifications.

--
Roland

This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.


 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      12-31-2003
"Scott" wrote:
:
: Thanks for your help Roland. Happy New Year!!

You're welcome Scott. Happy New Year to you also.

--
Roland

This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.

-Technet Script Center-
http://www.microsoft.com/technet/tre...er/default.asp
-MSDN Library-
http://msdn.microsoft.com/library/default.asp


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments