JavaScript to "click" Dynamically Created HyperLink

  • Thread starter Thread starter Dewek
  • Start date Start date
D

Dewek

I'm dynamically creating a few hyperlinks. After they're loaded, I want to
programmatically "click" the last one. I plan to use RegisterStartupScript
to do this, and just need the required JavaScript.

Thanks!
 
document.location = url;

No need to click anything. As you're adding this on the server, and
generating your hyperlinks on the server, you can certainly insert the URL
you want to redirect to in your JavaScript on the server.

Of course, you could just do a Response.Redirect, which would be faster. I
don't see the value of clikcing a hyperlink in a page immediately after
loading it. The page will never be seen, and all the HTML you generated to
go into it will be wasted.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Your points are well-taken and correct for when we're dealing with all of
this in one page; however in my scenario, I'm dealing with frames. Frame 'A'
contains a list of hyperlinks/images in a DataList. This list is populated
from database entries. I have implemented my own custom paging logic so that
only 10 are shown at a time. When more than 10 exist, the typcial "prev 1 2
3 4, next" type hyperlinks are shown above and below the DataList in frame
A.

My dilemma is this: In the page loaded into Frame 'B', a user can upload
more widgets (each of which gets an entry in the DataList in Frame A). By
default, when the page in Frame A is loaded, the custom paging logic shows
first page of data in the DataList. But what I want is for users to instead
see the *last* page of data in the DataList when they upload additional
widgets. So, in Frame B, the user clicks a button to upload additional
widgets, and the custom paging logic in Frame A needs to show the final
entries/last page-worth of data in its DataList.

Currently, the only thing tying the pages in frame A and B together
programmatically is the JScript [parent.leftFrame.location.reload(true)]
that is sent down via RegisterStartupScript from the "upload more widgets
now" button in frame B.

Any suggestions for how to accomplish this?

Thanks!
 
I figured it out: posted here for the benefit of anyone who might be
interested in the outcome:

scriptString = "<script language=JavaScript>parent.leftFrame.location='" +
strTempURL + "';</script>";

The proceeding line is executed in the code behind the page in Frame B (with
scriptString passed to RegisterStartupScript()).
The value of strTempURL includes the name of the ASPX page to be loaded into
Frame A - and ends with a QueryString value corresponding to the last
available page (per the custom paging logic). Doing this causes the code
behind the page in Frame A to execute in a manner identical to if a user had
clicked on the hyperlink for the last page listed in the menu provided by
the custom paging logic.

That's it.

Thanks to Mr. Spencer for the prompt on the JavaScript to be used
(.location=...).

-Dewek



Dewek said:
Your points are well-taken and correct for when we're dealing with all of
this in one page; however in my scenario, I'm dealing with frames. Frame 'A'
contains a list of hyperlinks/images in a DataList. This list is populated
from database entries. I have implemented my own custom paging logic so that
only 10 are shown at a time. When more than 10 exist, the typcial "prev 1 2
3 4, next" type hyperlinks are shown above and below the DataList in frame
A.

My dilemma is this: In the page loaded into Frame 'B', a user can upload
more widgets (each of which gets an entry in the DataList in Frame A). By
default, when the page in Frame A is loaded, the custom paging logic shows
first page of data in the DataList. But what I want is for users to instead
see the *last* page of data in the DataList when they upload additional
widgets. So, in Frame B, the user clicks a button to upload additional
widgets, and the custom paging logic in Frame A needs to show the final
entries/last page-worth of data in its DataList.

Currently, the only thing tying the pages in frame A and B together
programmatically is the JScript [parent.leftFrame.location.reload(true)]
that is sent down via RegisterStartupScript from the "upload more widgets
now" button in frame B.

Any suggestions for how to accomplish this?

Thanks!


Kevin Spencer said:
document.location = url;

No need to click anything. As you're adding this on the server, and
generating your hyperlinks on the server, you can certainly insert the URL
you want to redirect to in your JavaScript on the server.

Of course, you could just do a Response.Redirect, which would be faster. I
don't see the value of clikcing a hyperlink in a page immediately after
loading it. The page will never be seen, and all the HTML you generated to
go into it will be wasted.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
want
 
Dewek

I'm curious to hear your experience with frames. I've heard from a few people out here (including no less than Mr. Spencer himself) that they're a bit of a pain because ASP.NET doesn't provide much support, but I still like the basic functionality they provide--fixed location, the user can resize, scroll bars as necessary, etc.--which I'm guessing is why you are using them too

I'm wondering if you or somebody can comment on the feasibility of something like this: LeftPane has product list. User can click to add to shopping cart. RightPane has details of particular product, in synch with selections in left pane. User can specify additional attributes, special instructions, etc. and again can add to cart. BottomPane has the cart itself, a user control that shows whatever is in the cart. It provides its own logic for removing items

Because all of these are handling/raising events, I'm wondering if I can't make this work, but I'd love to try. Looking for a nudge in the right direction of the basic structure of something like this--e.g. you have a master page, it server-side redirects to the left page, that page tells the cart on the bottom to refresh itself, etc. Any thoughts are much appreciated

Regards

Bill Bor

----- Dewek wrote: ----

I figured it out: posted here for the benefit of anyone who might b
interested in the outcome

scriptString = "<script language=JavaScript>parent.leftFrame.location='"
strTempURL + "';</script>"

The proceeding line is executed in the code behind the page in Frame B (wit
scriptString passed to RegisterStartupScript())
The value of strTempURL includes the name of the ASPX page to be loaded int
Frame A - and ends with a QueryString value corresponding to the las
available page (per the custom paging logic). Doing this causes the cod
behind the page in Frame A to execute in a manner identical to if a user ha
clicked on the hyperlink for the last page listed in the menu provided b
the custom paging logic

That's it

Thanks to Mr. Spencer for the prompt on the JavaScript to be use
(.location=...)

-Dewe



Dewek said:
Your points are well-taken and correct for when we're dealing with all o
this in one page; however in my scenario, I'm dealing with frames. Fram 'A
contains a list of hyperlinks/images in a DataList. This list is populate
from database entries. I have implemented my own custom paging logic s tha
only 10 are shown at a time. When more than 10 exist, the typcial "prev
3 4, next" type hyperlinks are shown above and below the DataList in fram
A
My dilemma is this: In the page loaded into Frame 'B', a user can uploa
more widgets (each of which gets an entry in the DataList in Frame A). B
default, when the page in Frame A is loaded, the custom paging logic show
first page of data in the DataList. But what I want is for users t instea
see the *last* page of data in the DataList when they upload additiona
widgets. So, in Frame B, the user clicks a button to upload additiona
widgets, and the custom paging logic in Frame A needs to show the fina
entries/last page-worth of data in its DataList
Currently, the only thing tying the pages in frame A and B togethe
programmatically is the JScript [parent.leftFrame.location.reload(true)
that is sent down via RegisterStartupScript from the "upload more widget
now" button in frame B
Any suggestions for how to accomplish this
Thanks document.location = url
generating your hyperlinks on the server, you can certainly insert th URL
you want to redirect to in your JavaScript on the server. I
don't see the value of clikcing a hyperlink in a page immediately after
loading it. The page will never be seen, and all the HTML you generated to
go into it will be wasted.
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
want
 
From my experience with frames, I think you can do everything you described.
Each frame can hold an ASPX page that has whatever logic it needs in its
code-behind module. You make each page do whatever it needs to do all by
itself. Then, given the frames - you need to have a way to get the frames to
work together (e.g., user selects a product in one frame and the details
show up in another frame).

The two frame-coordination tasks I have tackled - and all I think you might
need - include (1) user selects something from the list in the left frame,
and the details show up in the right frame, and (2) users modify item
properties (or delete an item altogether) in the right frame and the left
frame gets updated to show the results of the user's actions.

In my case I handled task 1 by using the target= attribute. Check it out in
the following HTML:
<asp:DataList id="ThumbList" RepeatColumns="2" EnableViewState="false"
runat="server">
<ItemTemplate>
<table>
<tr>
<td>
<a href='PA_FullPhoto.aspx?ID=<%# DataBinder.Eval(Container.DataItem,
"PhotoID") %>' target="mainFrame">
<img src='Photos/Thumbs/<%# DataBinder.Eval(Container.DataItem,
"FileNameThumb") %>' width="80" height="80" border="0">
</a>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>

What results is a DataList that displays two columns of photo thumbnails
(could be a list of products you are selling...). When a user clicks on one
of them, the page PA_FullPhoto.aspx is opened in the frame designated by the
target= attribute. The querystring has a property named ID (populated at
runtime of course) that controls which photo (or widget) details are
displayed in the right frame. PA_FullPhoto.aspx, which is the page that
appears in the right frame with all the details, has code-behind logic that
retrieves the QueryString value of ID and retrieves the corresponding
details from the database, then renders to the browser/right frame. So this
accomplishes task 1 - user selects something in left frame and details show
up in right frame. Pretty straight-forward.

Task 2 is a bit trickier. What you are doing is updating the database from
the right frame, and then requiring that another frame (which essentially
knows nothing about what's going on in any other frame), to display the
results of the activity that took place in the right frame. To break the
solution down, all you have to do is (1) have the product detail/database
update logic get executed from the code behind the page that resides in the
right frame; (2) as the last step of that server-side logic, trigger some
JavaScript in the client that will cause the bottom-pane cart to redisplay
itself; and (3) in the bottom pane page's (cart page in your scenario)
code-behind logic, fetch the poduct detail information from the database
(this is the data that was just updated in the right frame). If you've been
around the block once or twice then doing steps 1 and 3 should be no
problem. Step 2 - triggering the JavaScript is the key to making this all
hang together. Your friend in this case is the RegisterStartupScript
procedure which will send some JavaScript down to the client - which will
execute it immediately on the client (with no action required on the part of
the user): Your variation of the following code needs to get executed as the
last step in the logic that updates the database from the right pane:

scriptString = "<script
language=JavaScript>parent.leftFrame.location.reload(true)</script>";

if(!this.IsClientScriptBlockRegistered("clientScript")){
this.RegisterStartupScript("clientScript", scriptString);
}

Notice the JavaScript buried in the scriptString:
parent.leftFrame.location.reload

For your case it would be something like
parent.bottomCartFrame.location.reload (or whatever name you give to your
bottom frame if not 'bottomCartFrame').

In my case I have a photo album and not a shopping cart - but everything I
did can be abstracted to do everything you'd need for a product catalog.

I hope this helps. Let me know if you'd like any of this clarified.

Dewek





Bill Borg said:
Dewek,

I'm curious to hear your experience with frames. I've heard from a few
people out here (including no less than Mr. Spencer himself) that they're a
bit of a pain because ASP.NET doesn't provide much support, but I still like
the basic functionality they provide--fixed location, the user can resize,
scroll bars as necessary, etc.--which I'm guessing is why you are using them
too.
I'm wondering if you or somebody can comment on the feasibility of
something like this: LeftPane has product list. User can click to add to
shopping cart. RightPane has details of particular product, in synch with
selections in left pane. User can specify additional attributes, special
instructions, etc. and again can add to cart. BottomPane has the cart
itself, a user control that shows whatever is in the cart. It provides its
own logic for removing items.
Because all of these are handling/raising events, I'm wondering if I can't
make this work, but I'd love to try. Looking for a nudge in the right
direction of the basic structure of something like this--e.g. you have a
master page, it server-side redirects to the left page, that page tells the
cart on the bottom to refresh itself, etc. Any thoughts are much
appreciated.
Regards,

Bill Borg

----- Dewek wrote: -----

I figured it out: posted here for the benefit of anyone who might be
interested in the outcome:

scriptString = "<script
language=JavaScript>parent.leftFrame.location='" +
strTempURL + "';</script>";

The proceeding line is executed in the code behind the page in Frame B (with
scriptString passed to RegisterStartupScript()).
The value of strTempURL includes the name of the ASPX page to be loaded into
Frame A - and ends with a QueryString value corresponding to the last
available page (per the custom paging logic). Doing this causes the code
behind the page in Frame A to execute in a manner identical to if a user had
clicked on the hyperlink for the last page listed in the menu provided by
the custom paging logic.

That's it.

Thanks to Mr. Spencer for the prompt on the JavaScript to be used
(.location=...).

-Dewek



Dewek said:
Your points are well-taken and correct for when we're dealing with all of
this in one page; however in my scenario, I'm dealing with frames.
Frame
'A'
contains a list of hyperlinks/images in a DataList. This list is populated
from database entries. I have implemented my own custom paging
logic so
that
only 10 are shown at a time. When more than 10 exist, the typcial
"prev 1
2
3 4, next" type hyperlinks are shown above and below the DataList in frame
A.
My dilemma is this: In the page loaded into Frame 'B', a user can
upload
more widgets (each of which gets an entry in the DataList in Frame A). By
default, when the page in Frame A is loaded, the custom paging logic shows
first page of data in the DataList. But what I want is for users to instead
see the *last* page of data in the DataList when they upload additional
widgets. So, in Frame B, the user clicks a button to upload additional
widgets, and the custom paging logic in Frame A needs to show the final
entries/last page-worth of data in its DataList.
Currently, the only thing tying the pages in frame A and B
together
programmatically is the JScript [parent.leftFrame.location.reload(true)]
that is sent down via RegisterStartupScript from the "upload more widgets
now" button in frame B.
Any suggestions for how to accomplish this?
Thanks!
document.location = url;
No need to click anything. As you're adding this on the server, and
generating your hyperlinks on the server, you can certainly insert
the
faster.
generated
I
 
Dewek

1. That you'd take the time to write this hefty response is much appreciated--thank you

2. I'm dying to try it out (might be a late night). I've known about RegisterStartupScript, but have only done the very basics, and for one had just been thinking about the resulting script as part of a stream rather than something that would fire right away. Powerful stuff

Cheers

Bil

----- Dewek wrote: ----

From my experience with frames, I think you can do everything you described
Each frame can hold an ASPX page that has whatever logic it needs in it
code-behind module. You make each page do whatever it needs to do all b
itself. Then, given the frames - you need to have a way to get the frames t
work together (e.g., user selects a product in one frame and the detail
show up in another frame)

The two frame-coordination tasks I have tackled - and all I think you migh
need - include (1) user selects something from the list in the left frame
and the details show up in the right frame, and (2) users modify ite
properties (or delete an item altogether) in the right frame and the lef
frame gets updated to show the results of the user's actions

In my case I handled task 1 by using the target= attribute. Check it out i
the following HTML
<asp:DataList id="ThumbList" RepeatColumns="2" EnableViewState="false
runat="server"><ItemTemplate><table><tr><td><a href='PA_FullPhoto.aspx?ID=<%# DataBinder.Eval(Container.DataItem
"PhotoID") %>' target="mainFrame"><img src='Photos/Thumbs/<%# DataBinder.Eval(Container.DataItem
"FileNameThumb") %>' width="80" height="80" border="0"></a></td></tr></table></ItemTemplate></asp:DataList

What results is a DataList that displays two columns of photo thumbnail
(could be a list of products you are selling...). When a user clicks on on
of them, the page PA_FullPhoto.aspx is opened in the frame designated by th
target= attribute. The querystring has a property named ID (populated a
runtime of course) that controls which photo (or widget) details ar
displayed in the right frame. PA_FullPhoto.aspx, which is the page tha
appears in the right frame with all the details, has code-behind logic tha
retrieves the QueryString value of ID and retrieves the correspondin
details from the database, then renders to the browser/right frame. So thi
accomplishes task 1 - user selects something in left frame and details sho
up in right frame. Pretty straight-forward

Task 2 is a bit trickier. What you are doing is updating the database fro
the right frame, and then requiring that another frame (which essentiall
knows nothing about what's going on in any other frame), to display th
results of the activity that took place in the right frame. To break th
solution down, all you have to do is (1) have the product detail/databas
update logic get executed from the code behind the page that resides in th
right frame; (2) as the last step of that server-side logic, trigger som
JavaScript in the client that will cause the bottom-pane cart to redispla
itself; and (3) in the bottom pane page's (cart page in your scenario
code-behind logic, fetch the poduct detail information from the databas
(this is the data that was just updated in the right frame). If you've bee
around the block once or twice then doing steps 1 and 3 should be n
problem. Step 2 - triggering the JavaScript is the key to making this al
hang together. Your friend in this case is the RegisterStartupScrip
procedure which will send some JavaScript down to the client - which wil
execute it immediately on the client (with no action required on the part o
the user): Your variation of the following code needs to get executed as th
last step in the logic that updates the database from the right pane

scriptString = "<scrip
language=JavaScript>parent.leftFrame.location.reload(true)</script>"

if(!this.IsClientScriptBlockRegistered("clientScript")){
this.RegisterStartupScript("clientScript", scriptString);
}

Notice the JavaScript buried in the scriptString:
parent.leftFrame.location.reload

For your case it would be something like
parent.bottomCartFrame.location.reload (or whatever name you give to your
bottom frame if not 'bottomCartFrame').

In my case I have a photo album and not a shopping cart - but everything I
did can be abstracted to do everything you'd need for a product catalog.

I hope this helps. Let me know if you'd like any of this clarified.

Dewek





Bill Borg said:
people out here (including no less than Mr. Spencer himself) that they're a
bit of a pain because ASP.NET doesn't provide much support, but I still like
the basic functionality they provide--fixed location, the user can resize,
scroll bars as necessary, etc.--which I'm guessing is why you are using them
too.something like this: LeftPane has product list. User can click to add to
shopping cart. RightPane has details of particular product, in synch with
selections in left pane. User can specify additional attributes, special
instructions, etc. and again can add to cart. BottomPane has the cart
itself, a user control that shows whatever is in the cart. It provides its
own logic for removing items.make this work, but I'd love to try. Looking for a nudge in the right
direction of the basic structure of something like this--e.g. you have a
master page, it server-side redirects to the left page, that page tells the
cart on the bottom to refresh itself, etc. Any thoughts are much
appreciated.
 
P.S. Works great. I've only done a simple frameset with dummy pages going back and forth, but have done enough to convince myself that I can push on. Thanks again to you and Kevin for your help

----- Bill Borg wrote: ----

Dewek

1. That you'd take the time to write this hefty response is much appreciated--thank you

2. I'm dying to try it out (might be a late night). I've known about RegisterStartupScript, but have only done the very basics, and for one had just been thinking about the resulting script as part of a stream rather than something that would fire right away. Powerful stuff

Cheers

Bil

----- Dewek wrote: ----

From my experience with frames, I think you can do everything you described
Each frame can hold an ASPX page that has whatever logic it needs in it
code-behind module. You make each page do whatever it needs to do all b
itself. Then, given the frames - you need to have a way to get the frames t
work together (e.g., user selects a product in one frame and the detail
show up in another frame)

The two frame-coordination tasks I have tackled - and all I think you migh
need - include (1) user selects something from the list in the left frame
and the details show up in the right frame, and (2) users modify ite
properties (or delete an item altogether) in the right frame and the lef
frame gets updated to show the results of the user's actions

In my case I handled task 1 by using the target= attribute. Check it out i
the following HTML
<asp:DataList id="ThumbList" RepeatColumns="2" EnableViewState="false
runat="server"><ItemTemplate><table><tr><td><a href='PA_FullPhoto.aspx?ID=<%# DataBinder.Eval(Container.DataItem
"PhotoID") %>' target="mainFrame"><img src='Photos/Thumbs/<%# DataBinder.Eval(Container.DataItem
"FileNameThumb") %>' width="80" height="80" border="0"></a></td></tr></table></ItemTemplate></asp:DataList

What results is a DataList that displays two columns of photo thumbnail
(could be a list of products you are selling...). When a user clicks on on
of them, the page PA_FullPhoto.aspx is opened in the frame designated by th
target= attribute. The querystring has a property named ID (populated a
runtime of course) that controls which photo (or widget) details ar
displayed in the right frame. PA_FullPhoto.aspx, which is the page tha
appears in the right frame with all the details, has code-behind logic tha
retrieves the QueryString value of ID and retrieves the correspondin
details from the database, then renders to the browser/right frame. So thi
accomplishes task 1 - user selects something in left frame and details sho
up in right frame. Pretty straight-forward

Task 2 is a bit trickier. What you are doing is updating the database fro
the right frame, and then requiring that another frame (which essentiall
knows nothing about what's going on in any other frame), to display th
results of the activity that took place in the right frame. To break th
solution down, all you have to do is (1) have the product detail/databas
update logic get executed from the code behind the page that resides in th
right frame; (2) as the last step of that server-side logic, trigger som
JavaScript in the client that will cause the bottom-pane cart to redispla
itself; and (3) in the bottom pane page's (cart page in your scenario
code-behind logic, fetch the poduct detail information from the databas
(this is the data that was just updated in the right frame). If you've bee
around the block once or twice then doing steps 1 and 3 should be n
problem. Step 2 - triggering the JavaScript is the key to making this al
hang together. Your friend in this case is the RegisterStartupScript
procedure which will send some JavaScript down to the client - which will
execute it immediately on the client (with no action required on the part of
the user): Your variation of the following code needs to get executed as the
last step in the logic that updates the database from the right pane:

scriptString = "<script
language=JavaScript>parent.leftFrame.location.reload(true)</script>";

if(!this.IsClientScriptBlockRegistered("clientScript")){
this.RegisterStartupScript("clientScript", scriptString);
}

Notice the JavaScript buried in the scriptString:
parent.leftFrame.location.reload

For your case it would be something like
parent.bottomCartFrame.location.reload (or whatever name you give to your
bottom frame if not 'bottomCartFrame').

In my case I have a photo album and not a shopping cart - but everything I
did can be abstracted to do everything you'd need for a product catalog.

I hope this helps. Let me know if you'd like any of this clarified.

Dewek





Bill Borg said:
people out here (including no less than Mr. Spencer himself) that they're a
bit of a pain because ASP.NET doesn't provide much support, but I still like
the basic functionality they provide--fixed location, the user can resize,
scroll bars as necessary, etc.--which I'm guessing is why you are using them
too.something like this: LeftPane has product list. User can click to add to
shopping cart. RightPane has details of particular product, in synch with
selections in left pane. User can specify additional attributes, special
instructions, etc. and again can add to cart. BottomPane has the cart
itself, a user control that shows whatever is in the cart. It provides its
own logic for removing items.make this work, but I'd love to try. Looking for a nudge in the right
direction of the basic structure of something like this--e.g. you have a
master page, it server-side redirects to the left page, that page tells the
cart on the bottom to refresh itself, etc. Any thoughts are much
appreciated.
 
Hi Bill,

Plese, call me "Kevin." :) My only caution regarding the use of Framesets is
that Sessions can be tricky, as browsers don't uniformly handle Sessions in
FrameSets and pop-up windows. It's a bit tricky to handle the client-side
aspect, as you have observed, since the frames can only talk to each other
on the client, using JavaScript. But I certainly don't think that FrameSets
are a bane to ASP.Net. Just to clarify.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Bill Borg said:
Dewek,

I'm curious to hear your experience with frames. I've heard from a few
people out here (including no less than Mr. Spencer himself) that they're a
bit of a pain because ASP.NET doesn't provide much support, but I still like
the basic functionality they provide--fixed location, the user can resize,
scroll bars as necessary, etc.--which I'm guessing is why you are using them
too.
I'm wondering if you or somebody can comment on the feasibility of
something like this: LeftPane has product list. User can click to add to
shopping cart. RightPane has details of particular product, in synch with
selections in left pane. User can specify additional attributes, special
instructions, etc. and again can add to cart. BottomPane has the cart
itself, a user control that shows whatever is in the cart. It provides its
own logic for removing items.
Because all of these are handling/raising events, I'm wondering if I can't
make this work, but I'd love to try. Looking for a nudge in the right
direction of the basic structure of something like this--e.g. you have a
master page, it server-side redirects to the left page, that page tells the
cart on the bottom to refresh itself, etc. Any thoughts are much
appreciated.
Regards,

Bill Borg

----- Dewek wrote: -----

I figured it out: posted here for the benefit of anyone who might be
interested in the outcome:

scriptString = "<script
language=JavaScript>parent.leftFrame.location='" +
strTempURL + "';</script>";

The proceeding line is executed in the code behind the page in Frame B (with
scriptString passed to RegisterStartupScript()).
The value of strTempURL includes the name of the ASPX page to be loaded into
Frame A - and ends with a QueryString value corresponding to the last
available page (per the custom paging logic). Doing this causes the code
behind the page in Frame A to execute in a manner identical to if a user had
clicked on the hyperlink for the last page listed in the menu provided by
the custom paging logic.

That's it.

Thanks to Mr. Spencer for the prompt on the JavaScript to be used
(.location=...).

-Dewek



Dewek said:
Your points are well-taken and correct for when we're dealing with all of
this in one page; however in my scenario, I'm dealing with frames.
Frame
'A'
contains a list of hyperlinks/images in a DataList. This list is populated
from database entries. I have implemented my own custom paging
logic so
that
only 10 are shown at a time. When more than 10 exist, the typcial
"prev 1
2
3 4, next" type hyperlinks are shown above and below the DataList in frame
A.
My dilemma is this: In the page loaded into Frame 'B', a user can
upload
more widgets (each of which gets an entry in the DataList in Frame A). By
default, when the page in Frame A is loaded, the custom paging logic shows
first page of data in the DataList. But what I want is for users to instead
see the *last* page of data in the DataList when they upload additional
widgets. So, in Frame B, the user clicks a button to upload additional
widgets, and the custom paging logic in Frame A needs to show the final
entries/last page-worth of data in its DataList.
Currently, the only thing tying the pages in frame A and B
together
programmatically is the JScript [parent.leftFrame.location.reload(true)]
that is sent down via RegisterStartupScript from the "upload more widgets
now" button in frame B.
Any suggestions for how to accomplish this?
Thanks!
document.location = url;
No need to click anything. As you're adding this on the server, and
generating your hyperlinks on the server, you can certainly insert
the
faster.
generated
I
 
Glad you like the solution. A couple of benefits of using frames include the
ability to scroll a list and select items near the bottom and the details
show up elsewhere on the screen without the whole screen, list and all,
getting reloaded. Without frames, scrolling to the bottom of a long list
would cause the details to scroll up and out of view. Then, selecting an
item would cause the details to re-appear for the selected item, but the
long list would scroll down and out of view. In my case I have a photo album
that lets the user view a long list of thumbnails. When they click on one,
the thumbnail list doesn't get reloaded (how many photo albums have you seen
that cause the entire page - thumbnails and all - to reload. Totally
unnecessary and it gives the page an amaturish feel). Another bonus of using
frames is that you can output cache "parts of the screen" (really whole
pages that just show up in their own frame) without having to chop up a page
into user controls and then caching those. IMHO, frames are just another
"color" in the Web programmer's pallette - so to speak. To say that frames
are evil is akin to a painter saying he doesn't like to use a certain color
in his paintings. By doing that, he's limiting the types and quality of his
work.

Dewek


Bill Borg said:
P.S. Works great. I've only done a simple frameset with dummy pages
going back and forth, but have done enough to convince myself that I can
push on. Thanks again to you and Kevin for your help.
----- Bill Borg wrote: -----

Dewek,

1. That you'd take the time to write this hefty response is much appreciated--thank you.

2. I'm dying to try it out (might be a late night). I've known about
RegisterStartupScript, but have only done the very basics, and for one had
just been thinking about the resulting script as part of a stream rather
than something that would fire right away. Powerful stuff.
Cheers,

Bill

----- Dewek wrote: -----

From my experience with frames, I think you can do everything you described.
Each frame can hold an ASPX page that has whatever logic it needs in its
code-behind module. You make each page do whatever it needs to do all by
itself. Then, given the frames - you need to have a way to get the frames to
work together (e.g., user selects a product in one frame and the details
show up in another frame).

The two frame-coordination tasks I have tackled - and all I think you might
need - include (1) user selects something from the list in the left frame,
and the details show up in the right frame, and (2) users modify item
properties (or delete an item altogether) in the right frame and the left
frame gets updated to show the results of the user's actions.

In my case I handled task 1 by using the target= attribute. Check it out in
the following HTML:
<asp:DataList id="ThumbList" RepeatColumns="2" EnableViewState="false"
runat="server"><ItemTemplate><table><tr><td><a
href='PA_FullPhoto.aspx?ID=<%# DataBinder.Eval(Container.DataItem,
"PhotoID") %>' target="mainFrame"><img src='Photos/Thumbs/<%# DataBinder.Eval(Container.DataItem,
"FileNameThumb") %>' width="80" height="80"
 
Hi Kevin : )

Please call me Jeff (okay, I'll fess up - I'm not Dewek!). Just wanted to
thank you for your help over the past couple of months with the JavaScript
stuff as I've been working on understanding how to get my frames to work the
way I need for them to.

Jeff


Kevin Spencer said:
Hi Bill,

Plese, call me "Kevin." :) My only caution regarding the use of Framesets is
that Sessions can be tricky, as browsers don't uniformly handle Sessions in
FrameSets and pop-up windows. It's a bit tricky to handle the client-side
aspect, as you have observed, since the frames can only talk to each other
on the client, using JavaScript. But I certainly don't think that FrameSets
are a bane to ASP.Net. Just to clarify.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Bill Borg said:
Dewek,

I'm curious to hear your experience with frames. I've heard from a few
people out here (including no less than Mr. Spencer himself) that they're a
bit of a pain because ASP.NET doesn't provide much support, but I still like
the basic functionality they provide--fixed location, the user can resize,
scroll bars as necessary, etc.--which I'm guessing is why you are using them
too.

I'm wondering if you or somebody can comment on the feasibility of
something like this: LeftPane has product list. User can click to add to
shopping cart. RightPane has details of particular product, in synch with
selections in left pane. User can specify additional attributes, special
instructions, etc. and again can add to cart. BottomPane has the cart
itself, a user control that shows whatever is in the cart. It provides its
own logic for removing items.
Because all of these are handling/raising events, I'm wondering if I
can't
make this work, but I'd love to try. Looking for a nudge in the right
direction of the basic structure of something like this--e.g. you have a
master page, it server-side redirects to the left page, that page tells the
cart on the bottom to refresh itself, etc. Any thoughts are much
appreciated.
Regards,

Bill Borg

----- Dewek wrote: -----

I figured it out: posted here for the benefit of anyone who might be
interested in the outcome:

scriptString = "<script
language=JavaScript>parent.leftFrame.location='" +
strTempURL + "';</script>";

The proceeding line is executed in the code behind the page in
Frame
B (with
scriptString passed to RegisterStartupScript()).
The value of strTempURL includes the name of the ASPX page to be loaded into
Frame A - and ends with a QueryString value corresponding to the last
available page (per the custom paging logic). Doing this causes the code
behind the page in Frame A to execute in a manner identical to if a user had
clicked on the hyperlink for the last page listed in the menu provided by
the custom paging logic.

That's it.

Thanks to Mr. Spencer for the prompt on the JavaScript to be used
(.location=...).

-Dewek
with
all of frames.
Frame logic so
that "prev 1
2
can
Frame
A). By
default, when the page in Frame A is loaded, the custom paging logic shows
first page of data in the DataList. But what I want is for users
to
instead
see the *last* page of data in the DataList when they upload additional
widgets. So, in Frame B, the user clicks a button to upload additional
widgets, and the custom paging logic in Frame A needs to show the final
entries/last page-worth of data in its DataList.
Currently, the only thing tying the pages in frame A and B together
programmatically is the JScript [parent.leftFrame.location.reload(true)]
that is sent down via RegisterStartupScript from the "upload more widgets
now" button in frame B.
Any suggestions for how to accomplish this?
Thanks!
document.location = url;
No need to click anything. As you're adding this on the
server,
insert
be
immediately
after generated
loaded,
 
Thanks very much, Jeff, for your kind encouragement! :)

--
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

Dewek said:
Hi Kevin : )

Please call me Jeff (okay, I'll fess up - I'm not Dewek!). Just wanted to
thank you for your help over the past couple of months with the JavaScript
stuff as I've been working on understanding how to get my frames to work the
way I need for them to.

Jeff


Kevin Spencer said:
Hi Bill,

Plese, call me "Kevin." :) My only caution regarding the use of
Framesets
is
that Sessions can be tricky, as browsers don't uniformly handle Sessions in
FrameSets and pop-up windows. It's a bit tricky to handle the client-side
aspect, as you have observed, since the frames can only talk to each other
on the client, using JavaScript. But I certainly don't think that FrameSets
are a bane to ASP.Net. Just to clarify.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

few
people out here (including no less than Mr. Spencer himself) that
they're
a
bit of a pain because ASP.NET doesn't provide much support, but I still like
the basic functionality they provide--fixed location, the user can resize,
scroll bars as necessary, etc.--which I'm guessing is why you are using them
something like this: LeftPane has product list. User can click to add to
shopping cart. RightPane has details of particular product, in synch with
selections in left pane. User can specify additional attributes, special
instructions, etc. and again can add to cart. BottomPane has the cart
itself, a user control that shows whatever is in the cart. It provides its
own logic for removing items. can't
make this work, but I'd love to try. Looking for a nudge in the right
direction of the basic structure of something like this--e.g. you have a
master page, it server-side redirects to the left page, that page tells the
cart on the bottom to refresh itself, etc. Any thoughts are much
appreciated.
language=JavaScript>parent.leftFrame.location='" + Frame
B (with the
code a
user had with
all of frames. is
populated typcial
"prev 1 DataList
in frame can Frame
A). By
users
to
instead
see the *last* page of data in the DataList when they upload additional
widgets. So, in Frame B, the user clicks a button to upload additional
widgets, and the custom paging logic in Frame A needs to show
the
final
entries/last page-worth of data in its DataList.
Currently, the only thing tying the pages in frame A and B together
programmatically is the JScript [parent.leftFrame.location.reload(true)]
that is sent down via RegisterStartupScript from the "upload
more
widgets
now" button in frame B.
Any suggestions for how to accomplish this?
Thanks!
document.location = url;
No need to click anything. As you're adding this on the
server,
and
generating your hyperlinks on the server, you can certainly
insert
the
URL
you want to redirect to in your JavaScript on the server.
Of course, you could just do a Response.Redirect, which
would
be immediately loaded,
 
Back
Top