How do I repeat pages.....

Discussion in 'ASP .Net' started by Jane sharpe, Dec 17, 2003.

  1. Jane sharpe

    Jane sharpe Guest

    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/
    Jane sharpe, Dec 17, 2003
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:%...
    > 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/
    Cowboy \(Gregory A. Beamer\), Dec 17, 2003
    #2
    1. Advertising

  3. Jane sharpe

    Jane sharpe Guest

    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/
    Jane sharpe, Dec 17, 2003
    #3
  4. 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" <> wrote in message
    news:...
    > 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/
    Cowboy \(Gregory A. Beamer\), Dec 17, 2003
    #4
  5. Jane sharpe

    Jane sharpe Guest

    Jane sharpe, Dec 17, 2003
    #5
  6. 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" <> wrote in message
    news:%...
    > 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/
    George Ter-Saakov, Dec 17, 2003
    #6
  7. Jane sharpe

    Jane sharpe Guest

    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/
    Jane sharpe, Dec 18, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. frank

    Repeat DataGrid?

    frank, Jul 11, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    412
    frank
    Jul 11, 2003
  2. SamIAm
    Replies:
    5
    Views:
    5,649
    S. Justin Gengo
    Jan 7, 2004
  3. Mike Lerch
    Replies:
    2
    Views:
    426
    Mike Lerch
    Mar 4, 2004
  4. .Net Newbie
    Replies:
    0
    Views:
    458
    .Net Newbie
    Jul 29, 2004
  5. =?Utf-8?B?R2lyaXNo?=

    How to repeat header of HTML/Gridview across pages

    =?Utf-8?B?R2lyaXNo?=, Nov 16, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    1,500
    =?Utf-8?B?R2lyaXNo?=
    Nov 17, 2007
Loading...

Share This Page