pass the control value from one web form to another form

Discussion in 'ASP .Net' started by tom, Nov 12, 2003.

  1. tom

    tom Guest

    Hi Experts,

    I want to pass the selectedDate value from my calender
    form to another web form or a web user control. Could you
    please show me how to do this?

    Thanks in advance.
     
    tom, Nov 12, 2003
    #1
    1. Advertising

  2. Tom,

    There are a number of choices to do so.

    Depending on your needs, you could use Server.Transfer or Response.Redirect
    and the query string.

    To use the query string

    Response.Redirect("pagetwo.aspx?date=" & selectedDate.ToString)

    Then on page two:

    Dim Date As Date = CType(Request.Querystring.Item("date"), Date)

    If you want to use Server.Transfer (Which would be more suited if a number
    of variables need to be passed to the second page.) I suggest reading up on
    it a bit more. It's fairly easy to do, but can be confusing for the user
    because they are moved to page two but their browser's address bar will
    still display the first page's url.

    If you want some quick code samples I have some in the code library of my
    web site: www.aboutfortunate.com. Just use the search box in the code
    library area and input: "Server.Transfer".

    Sincerely,

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche


    "tom" <> wrote in message
    news:00d201c3a947$75660be0$...
    > Hi Experts,
    >
    > I want to pass the selectedDate value from my calender
    > form to another web form or a web user control. Could you
    > please show me how to do this?
    >
    > Thanks in advance.
    >
     
    S. Justin Gengo, Nov 12, 2003
    #2
    1. Advertising

  3. Here's a nice, simple way to pass values from one page to another:
    (VB.NET code)

    'Add data to the context object before transferring
    Context.Items("myParameter") = x
    Server.Transfer("WebForm2.aspx")

    Then, in WebForm2.aspx:

    'Grab data from the context property
    Dim x as Integer = CType(Context.Items("myParameter"),Integer)

    Of course there are a number of ways to pass values from one page to
    another, such as using the querystring, cookies, session,
    context, saving to a temporary table in the database between each page, etc.
    You'll have to decide which technique is best for your application.
    Here are several good articles on the subject to help you decide.
    http://msdn.microsoft.com/msdnmag/issues/03/04/ASPNETUserState/default.aspx

    http://www.aspalliance.com/kenc/passval.aspx

    http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=600

    http://www.dotnetbips.com/displayarticle.aspx?id=79

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://Steve.Orr.net
    Hire top-notch developers at http://www.able-consulting.com



    "tom" <> wrote in message
    news:00d201c3a947$75660be0$...
    > Hi Experts,
    >
    > I want to pass the selectedDate value from my calender
    > form to another web form or a web user control. Could you
    > please show me how to do this?
    >
    > Thanks in advance.
    >
     
    Steve C. Orr [MVP, MCSD], Nov 12, 2003
    #3
  4. tom

    tom Guest

    Hi Steve and S. Justin,

    Thank you very much for your responses. I'm sorry that I
    didn't explain my problem more clearly on my previous
    mail. My problem is a different situation. On my page one
    there is textbox and the page two only contains a calendar
    control. I need to open page one first and click a button
    on page one will open the page two. After user selected a
    date from the calendar the page two will close and the
    date should be shown on the page one's textbox. I'm
    struggling with how to pass value back to page one when
    the page one is already opened and update page one's data?

    Please help me!
    Thanks in advance.

    >-----Original Message-----
    >Here's a nice, simple way to pass values from one page to

    another:
    >(VB.NET code)
    >
    >'Add data to the context object before transferring
    >Context.Items("myParameter") = x
    >Server.Transfer("WebForm2.aspx")
    >
    >Then, in WebForm2.aspx:
    >
    >'Grab data from the context property
    >Dim x as Integer = CType(Context.Items

    ("myParameter"),Integer)
    >
    >Of course there are a number of ways to pass values from

    one page to
    >another, such as using the querystring, cookies, session,
    >context, saving to a temporary table in the database

    between each page, etc.
    >You'll have to decide which technique is best for your

    application.
    >Here are several good articles on the subject to help you

    decide.

    >http://msdn.microsoft.com/msdnmag/issues/03/04/ASPNETUserS

    tate/default.aspx
    >
    >http://www.aspalliance.com/kenc/passval.aspx
    >
    >http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=600
    >
    >http://www.dotnetbips.com/displayarticle.aspx?id=79
    >
    >--
    >I hope this helps,
    >Steve C. Orr, MCSD, MVP
    >http://Steve.Orr.net
    >Hire top-notch developers at http://www.able-

    consulting.com
    >
    >
    >
    >"tom" <> wrote in

    message
    >news:00d201c3a947$75660be0$...
    >> Hi Experts,
    >>
    >> I want to pass the selectedDate value from my calender
    >> form to another web form or a web user control. Could

    you
    >> please show me how to do this?
    >>
    >> Thanks in advance.
    >>

    >
    >
    >.
    >
     
    tom, Nov 13, 2003
    #4
  5. Tom,

    I think this article is just what you need:

    http://www.vb2themax.com/Item.asp?PageID=TipBank&ID=614

    Sincerely,

    --
    S. Justin Gengo, MCP
    Web Developer

    Free code library at:
    www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzche


    "tom" <> wrote in message
    news:0e5401c3a9ee$cd69a7f0$...
    > Hi Steve and S. Justin,
    >
    > Thank you very much for your responses. I'm sorry that I
    > didn't explain my problem more clearly on my previous
    > mail. My problem is a different situation. On my page one
    > there is textbox and the page two only contains a calendar
    > control. I need to open page one first and click a button
    > on page one will open the page two. After user selected a
    > date from the calendar the page two will close and the
    > date should be shown on the page one's textbox. I'm
    > struggling with how to pass value back to page one when
    > the page one is already opened and update page one's data?
    >
    > Please help me!
    > Thanks in advance.
    >
    > >-----Original Message-----
    > >Here's a nice, simple way to pass values from one page to

    > another:
    > >(VB.NET code)
    > >
    > >'Add data to the context object before transferring
    > >Context.Items("myParameter") = x
    > >Server.Transfer("WebForm2.aspx")
    > >
    > >Then, in WebForm2.aspx:
    > >
    > >'Grab data from the context property
    > >Dim x as Integer = CType(Context.Items

    > ("myParameter"),Integer)
    > >
    > >Of course there are a number of ways to pass values from

    > one page to
    > >another, such as using the querystring, cookies, session,
    > >context, saving to a temporary table in the database

    > between each page, etc.
    > >You'll have to decide which technique is best for your

    > application.
    > >Here are several good articles on the subject to help you

    > decide.
    >
    > >http://msdn.microsoft.com/msdnmag/issues/03/04/ASPNETUserS

    > tate/default.aspx
    > >
    > >http://www.aspalliance.com/kenc/passval.aspx
    > >
    > >http://www.dotnetjunkies.com/tutorials.aspx?tutorialid=600
    > >
    > >http://www.dotnetbips.com/displayarticle.aspx?id=79
    > >
    > >--
    > >I hope this helps,
    > >Steve C. Orr, MCSD, MVP
    > >http://Steve.Orr.net
    > >Hire top-notch developers at http://www.able-

    > consulting.com
    > >
    > >
    > >
    > >"tom" <> wrote in

    > message
    > >news:00d201c3a947$75660be0$...
    > >> Hi Experts,
    > >>
    > >> I want to pass the selectedDate value from my calender
    > >> form to another web form or a web user control. Could

    > you
    > >> please show me how to do this?
    > >>
    > >> Thanks in advance.
    > >>

    > >
    > >
    > >.
    > >
     
    S. Justin Gengo, Nov 13, 2003
    #5
    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. et
    Replies:
    1
    Views:
    538
    Yunus Emre ALPĂ–ZEN [MCSD.NET]
    Jun 29, 2005
  2. Ken Fine
    Replies:
    4
    Views:
    2,899
    SteveT
    Dec 19, 2008
  3. Jay
    Replies:
    5
    Views:
    1,756
    Mr. Arnold
    Jun 29, 2010
  4. Rob R. Ainscough
    Replies:
    3
    Views:
    354
    Rob R. Ainscough
    Jun 14, 2005
  5. Robert Cohen
    Replies:
    3
    Views:
    295
    Andrew Durstewitz
    Jul 15, 2003
Loading...

Share This Page