0

I have a textbox filled at the page load. I want to check the value of the textbox is changed or not in the "update" button press. Any solution? TIA.

Aruna Prabhath
  • 206
  • 2
  • 10
  • 3
    Can you show some code to show what you've tried so far? – Eterm Mar 16 '22 at 10:54
  • You can save first text as a string. Then compare when update button pressed if current text equals first text string. Also please check this: https://stackoverflow.com/questions/9278859/asp-net-textbox-textchanged-event – Ertugrul Sungur Mar 16 '22 at 11:45

1 Answers1

0

Well, you could say use client side javascript.

But, you could also do this:

Say this text box:

            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <br />
            <asp:Button ID="Button1" runat="server" Text="Done - continue" OnClick="Button1_Click" />

And our code could be this:

   protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // code here to setup and load controls

            TextBox1.Text = "Dog";
            ViewState["TextBox1"] = "Dog";
        }
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        if (TextBox1.Text != (string)ViewState["TextBox1"])
        {
            // then text box was changed
        }
    }
Albert D. Kallal
  • 42,205
  • 3
  • 34
  • 51