Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. fpassing asp.net field

fpassing asp.net field

Scheduled Pinned Locked Moved ASP.NET
csharpquestionasp-nethelptutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dcof
    wrote on last edited by
    #1

    I am asking the following question since this is the first few C# asp.net 2010 web form pages I am working with at my company. My problem is I want to pass the value of orgName from the code listed below to a new web page called Next_Page.aspx as a session variable. The problem is by the time I get to the method called 'submit_button', I do not have the value of 'orgName' any longer. Thus can you tell me what I need to do to have the value of 'orgName' obtain from the 'FindOrg' available to the 'submit_button' method? If the value or orgname is within the (object sender, EventArgs e) of the SubmitButton method can you tell me how to access this value? The code listed below is all from the same web page called first.aspx.cs. The following is the current code: [^]protected void FindOrg(object sender, EventArgs e) { try { String strOrgSql = ""; String orgName = txtOrgName.Text.Trim(); } catch (Exception ex) { //do something } } protected void submit_button(object sender, EventArgs e) { try { want orgname value here Session["orgname"] = orgname; Response.Redirect("~/Next_Page.aspx"); } catch (Exception ex) { // do something } } [^]

    N 1 Reply Last reply
    0
    • D dcof

      I am asking the following question since this is the first few C# asp.net 2010 web form pages I am working with at my company. My problem is I want to pass the value of orgName from the code listed below to a new web page called Next_Page.aspx as a session variable. The problem is by the time I get to the method called 'submit_button', I do not have the value of 'orgName' any longer. Thus can you tell me what I need to do to have the value of 'orgName' obtain from the 'FindOrg' available to the 'submit_button' method? If the value or orgname is within the (object sender, EventArgs e) of the SubmitButton method can you tell me how to access this value? The code listed below is all from the same web page called first.aspx.cs. The following is the current code: [^]protected void FindOrg(object sender, EventArgs e) { try { String strOrgSql = ""; String orgName = txtOrgName.Text.Trim(); } catch (Exception ex) { //do something } } protected void submit_button(object sender, EventArgs e) { try { want orgname value here Session["orgname"] = orgname; Response.Redirect("~/Next_Page.aspx"); } catch (Exception ex) { // do something } } [^]

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      orgname is a variable local to the FindOrg method. It can't be used outside of that method. Use txtOrgName.Text.Trim();


      No comment

      D 1 Reply Last reply
      0
      • N Not Active

        orgname is a variable local to the FindOrg method. It can't be used outside of that method. Use txtOrgName.Text.Trim();


        No comment

        D Offline
        D Offline
        dcof
        wrote on last edited by
        #3

        How would I declare the variable so I can use it outside of this method? Would I set it up as a session variable?

        B N 2 Replies Last reply
        0
        • D dcof

          How would I declare the variable so I can use it outside of this method? Would I set it up as a session variable?

          B Offline
          B Offline
          Brij
          wrote on last edited by
          #4

          You can put the variable at Class level. You can also put it in session variable and can be accessed at any other pages as well

          Cheers!! Brij Microsoft MVP ASP.NET/IIS Visit my Blog: http://brijbhushan.net

          1 Reply Last reply
          0
          • D dcof

            How would I declare the variable so I can use it outside of this method? Would I set it up as a session variable?

            N Offline
            N Offline
            Not Active
            wrote on last edited by
            #5

            In the case you have shown you don't need to use a variable to hold the value until it is passed to session, assign the value from the control directly to you e session variable

            Session["orgname"] = txtOrgName.Text.Trim();


            No comment

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups