nick_green
nick_green

Reputation: 1664

ASP.NET viewstate update without javascript

Hy,

how to update my viewstate on model variable value changed? To make it more clear lets take an example.

I have 3 variables in my model. One of them is bool and other two are strings. when I run my application I have a form of one checkbox. When I click on checkbox I want those two string values appear as a input values and when I click on the checkbox again I want to make them disappear again.

How could I make this happen without javascript?

Upvotes: 0

Views: 104

Answers (1)

Nazir Ullah
Nazir Ullah

Reputation: 610

when Using simple web form application just use

on aspx page

 <asp:CheckBox Text="Check" Checked="false" ID="MyCheckBox" runat="server" AutoPostBack="true" OnCheckedChanged="MyCheckBox_CheckedChanged" />

on aspx.cs page

 protected void MyCheckBox_CheckedChanged(object sender, EventArgs e)
        {
            if (MyCheckBox.Checked)
            {
                Response.Write("CheckeD");
            }
            else
            {
                Response.Write("Un CheckeD");
            }
        }

Upvotes: 1

Related Questions