Sharing Data Between Forms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kcowley
    New Member
    • May 2007
    • 1

    Sharing Data Between Forms

    I have two forms, the first has a textbox with customer name (read only) and a button to load the second form which has some textboxes for enter customer name, etc. When I populate these textboxes from SQL and click ok to close the second form I want the customer name from a textbox to return to the first form.

    How do I do this? Return values? Global variables? Any help would be greatly appreciated!
  • Abdul Haque
    New Member
    • May 2007
    • 17

    #2
    try using the hidden control, declare a html contol of type hidden, then set its value on the Form2 , when you reopen the form 1 you can get the value using Requets("hdnCon trolName");

    Comment

    • TRScheel
      Recognized Expert Contributor
      • Apr 2007
      • 638

      #3
      Originally posted by Abdul Haque
      try using the hidden control, declare a html contol of type hidden, then set its value on the Form2 , when you reopen the form 1 you can get the value using Requets("hdnCon trolName");
      Or set a session variable... or cookie, though I would suggest session variables just because I am partial to them.


      Session["FirstName"] = "HisName";
      ...
      string FirstName = (string)Session["FirstName"];

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Is this a web application or a windows application?

        There is a sticky at the top of the forum the begs people to post correctly. Please read it as it sets a format for discussion titles.

        Comment

        • Abdul Haque
          New Member
          • May 2007
          • 17

          #5
          Originally posted by TRScheel
          Or set a session variable... or cookie, though I would suggest session variables just because I am partial to them.


          Session["FirstName"] = "HisName";
          ...
          string FirstName = (string)Session["FirstName"];
          The suggestion is good, however please note creating a session or cookie require utilization of resource at client end, beside this making severe use of session variable is not a good practice.
          In case if user wishes to create a session/cookie then please do abandon the session/delete the cookie once its use is over.

          Comment

          • nmsreddi
            Contributor
            • Jul 2006
            • 366

            #6
            Hello

            If its a web application you can use java script to solve your

            problem ,you can get the by gooling with key word as java script for popup i already send the some long time back for this you can easily search it ,dont try either cookies or sessions unless they are required mandatorly

            Good Luck

            Comment

            • Frinavale
              Recognized Expert Expert
              • Oct 2006
              • 9749

              #7
              Originally posted by kcowley
              I have two forms, the first has a textbox with customer name (read only) and a button to load the second form which has some textboxes for enter customer name, etc. When I populate these textboxes from SQL and click ok to close the second form I want the customer name from a textbox to return to the first form.

              How do I do this? Return values? Global variables? Any help would be greatly appreciated!

              Please see this article on what Sessions are and how to use them

              Comment

              • TRScheel
                Recognized Expert Contributor
                • Apr 2007
                • 638

                #8
                Originally posted by Abdul Haque
                The suggestion is good, however please note creating a session or cookie require utilization of resource at client end, beside this making severe use of session variable is not a good practice.
                In case if user wishes to create a session/cookie then please do abandon the session/delete the cookie once its use is over.

                This is true, but it also takes some of the load off the server, which is why I am partial to them.

                Good points though

                Comment

                • mehrdada
                  New Member
                  • May 2007
                  • 2

                  #9
                  Why don't you just create a class with friend shared variables and use them in the other form?

                  Comment

                  Working...