Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Transfering info from one web form to another (c# ASP.Net)

  • 20-04-2009 03:05PM
    #1
    Closed Accounts Posts: 16,066 ✭✭✭✭


    Hey all,

    i'm doing a project in college at the moment. On one web form I have the user entering a number. I need to use this number in a different form and I can't work out how to do this, even after hours of googling :rolleyes::o

    Can anybody out there help me?!

    Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 26,449 ✭✭✭✭Creamy Goodness


    you could achieve it by using sessions,

    something like this may help http://msdn.microsoft.com/en-us/library/ms178581.aspx

    store the number entered by the user in a session, then when you need to use it again, retrieve the value from the session and input it where ever ya need it.


  • Registered Users, Registered Users 2 Posts: 527 ✭✭✭Sean^DCT4


    If you are passing just an integer to another web form then I would suggest using the QueryString. Request.QueryString["whatever"].

    Example:

    Button Click Event on page calls:
    Response.Redirect("APageWithQueryString.aspx?MyPassedVal=123");
    

    On your APageWithQueryString.aspx page you can retrieve the value using
    int myPassedInValue = Convert.ToInt32(Request.Querystring["MyPassedVal"]);
    

    Note: MyPassedVal is the querystring field. 123 can be any string you want


  • Closed Accounts Posts: 522 ✭✭✭comer_97


    you could also use a HTTPContext too. They have made it very unintuitive.


  • Registered Users, Registered Users 2 Posts: 2,793 ✭✭✭John_Mc


    comer_97 wrote: »
    you could also use a HTTPContext too. They have made it very unintuitive.

    What do you mean?


  • Closed Accounts Posts: 522 ✭✭✭comer_97


    John_Mc wrote: »
    What do you mean?

    Do you mean how it is unintuitive or how to use a httpcontext?

    HTTPContext stuff

    As for it being unintuitive, why doesn't .net embrace the humble html form? It's worked well for years and works well, why change it?

    Once .net gets to the presentation layer it is a shambles. It's use of css is terrible and trying to do anything clientside is really complex, unnecessarily so.

    Hopefully XAML will change this but I've yet to use it professionally.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 12,027 ✭✭✭✭Giblet


    You can use CSSFriendly adapters, and the new MVC framework is pretty decent, doesn't rely on postbacks!

    Still, there were some mistakes made initially, but they are trying to rectify them.


  • Registered Users, Registered Users 2 Posts: 885 ✭✭✭clearz


    comer_97 wrote: »
    why doesn't .net embrace the humble html form? It's worked well for years and works well, why change it?
    You can use HTML foms perfectly easily by just using the HTML controls instead of the Web Controls
    comer_97 wrote: »
    Once .net gets to the presentation layer it is a shambles. It's use of css is terrible and trying to do anything
    clientside is really complex, unnecessarily so.

    You really have 3 different choices with .NET
    HTML Controls
    Web Forms
    MVC
    Each have their uses and misuses. But there is something for everyone and every type of site/application here
    comer_97 wrote: »
    Hopefully XAML will change this but I've yet to use it professionally.
    XAML's only use on the web is with Silverlight and adds nothing new to plain old HTML pages.


Advertisement