Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How do I repeat pages.....

Reply
Thread Tools

How do I repeat pages.....

 
 
Jane sharpe
Guest
Posts: n/a
 
      12-17-2003
Hi

I have an aspx page that is called with an ID parameter, it then performs a SQL statement using the ID field and displays some data on the page. It works a treat

What I want to do however, is to run it n number of times with different ID's - and have the results displayed in one page one after the other, e.g

if the user selects 4 ID's then the page will displa

Page for ID

Page for ID

Page for ID

Page for ID

Can anyone point me in the right direction to achieve this please

Jan


---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      12-17-2003
For a limited number of choices, you can simply add four panels and hide all
but the one with the info you wish to show. This is not the best solution
for flexibility, but it is a rather fast and easy one to implement.

For more scalability, you can create four user controls and dynamically load
the one that fits the ID. This allows you to add extra choices without
having to recode the page or change the architecture. Another option is to
create four pages and Server.Transfer the person to the correct page. With
Server.Transfer, the user will still see the URL:

http://mysite.com/choicePage.aspx?ID=1

instead of

http://mysite.com/page1.aspx

In many respects, this is more maintainable, as you can have a designer
change the pages, including content elements, with his/her favorite HTML
editor (FrontPage, Dreamweaver).

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Jane sharpe" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi,
>
> I have an aspx page that is called with an ID parameter, it then performs

a SQL statement using the ID field and displays some data on the page. It
works a treat.
>
> What I want to do however, is to run it n number of times with different

ID's - and have the results displayed in one page one after the other, e.g -
>
> if the user selects 4 ID's then the page will display
>
> Page for ID1
> +
> Page for ID2
> +
> Page for ID3
> +
> Page for ID4
>
> Can anyone point me in the right direction to achieve this please ?
>
> Jane
>
>
> ---
> Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/



 
Reply With Quote
 
 
 
 
Jane sharpe
Guest
Posts: n/a
 
      12-17-2003
Thanks Gregory,

I think I understand what you're saying (sorry, I'm still learning) - th enumber of pages to join is variable from 1 to n, does this effect your answer at all ?

Jane

---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
 
Reply With Quote
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      12-17-2003
With 1 to n, I would not use panels (first suggestion). The controls or
pages with Server.Transfer both apply. The decision of which to do is
largely based on who maintains content items. If you have a graphic designer
maintaining the content, I would go with pages, as controls require the
person to either use notepad or have a copy of a .NET editor (Visual Studio
..NET, SharpDevelop, et al).

The basic tree goes like this, with pages:
----------------------------------------

Assuming URL format of
http://mysite.com/pageLoader.aspx?ID=1

pageLoader.aspx - page that gets ID
page1.aspx
page2.aspx
page3.aspx
page4.aspx

In pageLoader.aspx:

VB.NET
Dim id As String = Request("ID").ToString()
Server.Transfer("page" & id & ".aspx")

C#
string id = Request("ID").ToString();
Server.Transfer("page" + id + ".aspx");


Controls
---------
Controls gets a bit more complex (and more difficult to maintain for graphic
designers/HTML artists).

pageLoader.aspx - for consistency
page1.ascx
page2.ascx
page3.ascx
page4.ascx

In pageLoader.aspx you will drag a panel on the page in design view. I will
use Panel1, as that is the default, but you would probably want to be more
descriptive. In the CodeBehind (.vb or .cs file), you will use a statement
like this:

VB.NET
Dim id As Integer = Convert.ToInt32(Request("ID"))
Select Case id
Case 1
Panel1.Controls.Add(page1)
Case 2
Panel1.Controls.Add(page2)
Case 3
Panel1.Controls.Add(page3)
End Select

C#
int id = Convert.ToInt32(Request("ID"));
switch(id)
{
case 1:
Panel1.Controls.Add(page1);
break;
case 2:
Panel1.Controls.Add(page2);
break;
case 3:
Panel1.Controls.Add(page3);
break;
}

In this example, you can name the added controls anything you want, so

Panel1.Controls.Add(Administrators)
Panel1.Controls.Add(Users)

You would then make controls Administrators.ascx and Users.ascx.

NOTE: You can also apply this type of logic to example1 (with pages), if you
wish to have the pages by role (Administrators, Users, ReportUsers, et al)
instead of numbers (page1, page2, page3).

Back to pages
--------------

Assuming the following pages

pageLoader.aspx
Admin.aspx
User.aspx
ReportUser.aspx

VB.NET
Dim id As Integer = Convert.ToInt32(Request("ID"))
Select Case id
Case 1
Server.Transfer("Admin.aspx")
Case 2
Server.Transfer("User.aspx")
Case 3
Server.Transfer("ReportUser.aspx")
End Select

C#
int id = Convert.ToInt32(Request("ID"));
switch(id)
{
case 1:
Server.Transfer("Admin.aspx");
break;
case 2:
Server.Transfer("User.aspx");
break;
case 3:
Server.Transfer("ReportUser.aspx");
break;
}
Okay, you are probably at information overload right now. I would suggest
trying the page version first, as it is the easiest to design for. You can
either use the simplified version (page1.aspx, et al) or the role version
(Admin.aspx). I would suggest matching ID to page#.aspx, as it is easier.
You can move over to the role based version, if it makes more sense, after
you have things working.

For your own experience, experiment with the controls version at some time,
as you might find it better suited for your app(s) in the long run.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Jane sharpe" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks Gregory,
>
> I think I understand what you're saying (sorry, I'm still learning) - th

enumber of pages to join is variable from 1 to n, does this effect your
answer at all ?
>
> Jane
>
> ---
> Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/



 
Reply With Quote
 
Jane sharpe
Guest
Posts: n/a
 
      12-17-2003
Thanks Gregory, I'll give it a go later tonight.

Jane

---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
 
Reply With Quote
 
George Ter-Saakov
Guest
Posts: n/a
 
      12-17-2003
I would create UserControl which creates output of one page.
And then i would add it to the page itself as many time as i need.

George.

"Jane sharpe" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi,
>
> I have an aspx page that is called with an ID parameter, it then performs

a SQL statement using the ID field and displays some data on the page. It
works a treat.
>
> What I want to do however, is to run it n number of times with different

ID's - and have the results displayed in one page one after the other, e.g -
>
> if the user selects 4 ID's then the page will display
>
> Page for ID1
> +
> Page for ID2
> +
> Page for ID3
> +
> Page for ID4
>
> Can anyone point me in the right direction to achieve this please ?
>
> Jane
>
>
> ---
> Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/



 
Reply With Quote
 
Jane sharpe
Guest
Posts: n/a
 
      12-18-2003
Hmmmm, I've had a go at the suggestions Gregory, I think I understand them but I dont think they do what I need.... I'll explain a bit more....

Imagine I have Pageload.aspx, which currently calls ShowName.aspx for a particlar Id on a buttonClick event... so at the moment in my buttonclick I have ....

Response.Redirect("ShowName.aspx?Id=1")

Which takes me to a ShowName.aspx and correctly shows me "John Smith"

Now I want to upgrade this, so that a user can select multiple Id's, and they all get shown on 1 page after the buttonclick event, so if a user selects Id's 1,3 and 5 (could be n number) I loop around the Id's each time building some "temporary page" which I can then view with a Response.Redirect or something similar, which will show

John Smith
Jane Green
Bob White

Being Id's 1, 3 5 respectively. I'm sorry If I've misunderstood you, but I couldnt make your suggestions behave in this way.... thanks, Jane

---
Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Important Information About MCP Welcome Kits..repeat posting Microsoft Certification 3 08-17-2012 02:21 PM
Guru's Challenge: How to Repeat multiple Controls in a Page in an abnormal situation .Net Newbie ASP .Net 0 07-29-2004 04:36 PM
Can the ItemHeader repeat for each "section break" in a Repeater? Mike Lerch ASP .Net 2 03-04-2004 04:18 PM
Repeater Control: How to repeat in rows of x? SamIAm ASP .Net 5 01-07-2004 06:00 PM
Repeat DataGrid? frank ASP .Net 0 07-11-2003 12:21 PM



Advertisments