value from another form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prasannagodbole67
    New Member
    • Mar 2008
    • 3

    value from another form

    IN c# : how to get value from another form ............... ............... ............


    In 1st form there is a textBox

    that textbox value i want to another form in label.......
  • Waazzzii
    New Member
    • Jan 2008
    • 6

    #2
    Im assuming your second form is on a second page because you cannot have multiple forms on a page...

    There are several ways to do this:

    1. Via request:

    C#
    string url = "yourpage.aspx? Textbox=" + YourTextboxId.T ext;
    Response.Redire ct(url);

    HTML
    <asp:TextBox runat="server" id="YourTextbox Id" ... ></asp:TextBox>

    - To retrieve the value in C# : Request.QuerySt ring["Textbox"];

    2. Using Session state:

    Session["TextboxVal ue"] = YourTextboxId.T ext;

    - To retrieve: Session["TextboxVal ue"];

    Hope this helps...

    Comment

    • prasannagodbole67
      New Member
      • Mar 2008
      • 3

      #3
      sir ,,,

      in a windows application ..........

      i want code.....


      i think like its a website code.....

      Comment

      • r035198x
        MVP
        • Sep 2006
        • 13225

        #4
        Originally posted by prasannagodbole 67
        sir ,,,

        in a windows application ..........

        i want code.....


        i think like its a website code.....
        How are the forms related?

        Comment

        • prasannagodbole67
          New Member
          • Mar 2008
          • 3

          #5
          formating

          Originally posted by r035198x
          How are the forms related?

          today i got my ans......


          from

          constructor:-

          1st form :-

          private void f1_b1_Click(obj ect sender, EventArgs e)
          {

          Form2 f2 = new Form2(f1_t1.Tex t); this.Hide();
          f2.Show();

          }


          2nd form :-

          public partial class Form2 : Form
          {
          public Form2(string value)
          {
          InitializeCompo nent();

          f2_l2.Text = value;

          }
          Last edited by prasannagodbole67; Apr 2 '08, 11:33 AM. Reason: bold is imp

          Comment

          • kenobewan
            Recognized Expert Specialist
            • Dec 2006
            • 4871

            #6
            Originally posted by prasannagodbole 67
            sir ,,,

            in a windows application ..........

            i want code.....


            i think like its a website code.....
            In your first post please state whether it is windows, saves everybody's time. Please read the posting guidelines before your next post. Thanks.

            MODERATOR

            Comment

            Working...