2 Replies - 1139 Views - Last Post: 10 December 2012 - 04:13 AM Rate Topic: -----

#1 Xna4life  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 78
  • Joined: 21-February 12

ASP.NET post textbox after button click

Posted 09 December 2012 - 03:11 PM

So im just using an ASP.NET atm

Iv added 4 textboxes from the toolbox TextBox1, TextBox2, TextBox3, TextBox 4 and a button 'button1'

I want the user to enter data into the textboxs, compare them by .length and produce the output in order.

So before ordering them I am just trying to display them in the order of boxes textbox1, textbox2, textbox3.

protected void Button1_Click(object sender, EventArgs e)
    {
        DatesInOrderTextBox.Text = "Dates in order are" + TextBox1 + ", " + TextBox2 + ", " + TextBox3;
}



After that I intend to do something like the following

        //date 1 is biggest
        if (date1.Length > date2.Length && date1.Length > date3.Length)
        {
            //date 2 is 2nd & date 3 is 3rd
            if (date2.Length > date3.Length)
            {
                FirstDateOrder = date1;
                SecondDateOrder = date2;
                ThirdDateOrder = date3;

              System.Windows.Forms.MessageBox.Show("Order is 1, 2, 3");

             //   System.Windows.Forms.MessageBox.Show("Order is:" + FirstDateOrder + ", " + SecondDateOrder + ", " + ThirdDateOrder);

                ViewBag.DateOrder = "Order is 1,2,3";

                return RedirectToAction("Index");
            }

            //date 3 is 2nd & date 2 is 3rd
            else
            {
                FirstDateOrder = date1;
                SecondDateOrder = date3;
                ThirdDateOrder = date2;

                System.Windows.Forms.MessageBox.Show("Order is 1, 3, 2");

                return RedirectToAction("Index");
            }
}


Although when I click the button textbox4 is displaying

Dates in order areSystem.Web.UI.WebControls.TextBox, System.Web.UI.WebControls.TextBox, System.Web.UI.WebControls.TextBox



prob something simple just dont know how to fix it...thank you guys

Is This A Good Question/Topic? 0
  • +

Replies To: ASP.NET post textbox after button click

#2 souptoy  Icon User is offline

  • D.I.C Head


Reputation: 54
  • View blog
  • Posts: 244
  • Joined: 17-January 08

Re: ASP.NET post textbox after button click

Posted 09 December 2012 - 03:18 PM

Try using Textbox.Text. What you're seeing is the default ToString() of the Textboxes. .Text exposes the value that the textbox has.

This post has been edited by souptoy: 09 December 2012 - 03:22 PM

Was This Post Helpful? 1
  • +
  • -

#3 Xna4life  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 78
  • Joined: 21-February 12

Re: ASP.NET post textbox after button click

Posted 10 December 2012 - 04:13 AM

View Postsouptoy, on 09 December 2012 - 03:18 PM, said:

Try using Textbox.Text. What you're seeing is the default ToString() of the Textboxes. .Text exposes the value that the textbox has.

Ahh thats great thanks for the reply, worked like a treat
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1