problem with 2 forms and 1 textbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BlackChaos
    New Member
    • Sep 2007
    • 2

    problem with 2 forms and 1 textbox

    hi @ all,

    i have a little problem...
    i have 2 forms (form1 and form2)

    on form1 threre is a textbox TB1 and a button BT1
    by clicking on BT1 i switch to form2

    so now the problem:
    in TB1 is a text which i want to give out via a messagebox on form2... but form2 don't know about the TB1... also when i save the content of TB1 in a string at form1 an switch to form2 the string don't be known

    could anybody help me?

    PS: sorry about the teriible english, i hope you can understand it ^^
    thanks
  • Sasi Rekha
    New Member
    • Aug 2007
    • 18

    #2
    hi,
    assume you have a value in TB1 in form1
    on BT1 click event carry that TB1 value in the session like

    void BT1_click(sende r,e)
    {
    session["TB1value"]=TB1.text;
    }


    in form2 page load event

    pageload
    {
    show("session["TB1value"].Tostring()");
    }
    function for show.
    public static void Show( string sMessage )
    {
    if( !m_executingPag es.Contains( HttpContext.Cur rent.Handler ) )
    {
    Page executingPage = HttpContext.Cur rent.Handler as Page;
    if( executingPage != null )
    {
    Queue messageQueue = new Queue();
    messageQueue.En queue( sMessage );
    m_executingPage s.Add( HttpContext.Cur rent.Handler, messageQueue );
    executingPage.U nload += new EventHandler( ExecutingPage_U nload );
    }
    }
    else
    {
    Queue queue = (Queue) m_executingPage s[HttpContext.Cur rent.Handler ];

    queue.Enqueue( sMessage );
    }
    }

    hope this may help
    Originally posted by BlackChaos
    hi @ all,

    i have a little problem...
    i have 2 forms (form1 and form2)

    on form1 threre is a textbox TB1 and a button BT1
    by clicking on BT1 i switch to form2

    so now the problem:
    in TB1 is a text which i want to give out via a messagebox on form2... but form2 don't know about the TB1... also when i save the content of TB1 in a string at form1 an switch to form2 the string don't be known

    could anybody help me?

    PS: sorry about the teriible english, i hope you can understand it ^^
    thanks

    Comment

    • rohitbce
      New Member
      • Aug 2007
      • 30

      #3
      if it is a web application then use a query string or you can use session also
      Rohit Jain

      Comment

      • Shashi Sadasivan
        Recognized Expert Top Contributor
        • Aug 2007
        • 1435

        #4
        And if its not a web aplication
        send form1 as a parameter to form2
        and access
        Code:
        TB1 using form1.TB1.Text;

        Comment

        • BlackChaos
          New Member
          • Sep 2007
          • 2

          #5
          jo thanks,
          i've found also a solution...

          it's a little bit easier ^^

          form1:
          private void button1_Click(o bject sender, System.EventArg s e)
          {
          Form2 frm=new Form2(textBox1. Text);
          frm.Show();
          }

          form2:
          public Form2(string strTextBox)
          {
          InitializeCompo nent();
          label1.Text=str TextBox;
          }


          now, i see, that i forgot to say, that i am programming in c# .net, but it's no problem, thx for your solution

          Comment

          Working...