dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: passing field value in asp.net 2010

Hybrid View

  1. #1
    Join Date
    Sep 2011
    Posts
    34

    passing field value in asp.net 2010

    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:

    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
     
                }
     
            }
    Last edited by GremlinSA; November 2nd, 2011 at 02:12 PM. Reason: added code tags..

  2. #2
    Join Date
    Feb 2002
    Location
    Mumbai, India
    Posts
    242

    Re: passing field value in asp.net 2010

    Hi,

    You would not get the org val in submit as it is a local variable. Either declare it globally else set the session in the 1st function itself
    Hope this helps. If it does, then rate it.
    ----
    Rohit

  3. #3
    Join Date
    Sep 2011
    Posts
    34

    Re: passing field value in asp.net 2010

    How would I declare the column globally? Would I call the varirable public and place it within the highest level namespace? The location would be near where the class or partial class are defined?

  4. #4
    Join Date
    Feb 2002
    Location
    Mumbai, India
    Posts
    242

    Re: passing field value in asp.net 2010

    You would have to declare it at the page level
    Code:
    public partial class first : System.Web.UI.Page
        {
            #region Public Variables
            String orgName;
           #endregion
    //Rest of the code goes here
    Hope this helps. If it does, then rate it.
    ----
    Rohit

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)