there are one textbox two buttons(Edit/Update,cancel)
as you know when we click on edit the textbox's read only=false and when click on update textbox become read only..
i tried it but when click on update the textbox text disappears..
home.cs
ProfileCommon p;
protected void Button1_Click(object sender, EventArgs e)
{
if (Button1.Text == "Edit")
{
TextBox1.ReadOnly = false;
Button1.Text = "Update";
}
else if (Button1.Text == "Update")
{
TextBox1.ReadOnly = true;
p.status = TextBox1.Text;
Button1.Text = "Edit";
}
}
Thanks !

Dipa AhujaPosted Feb 15, 2010, 11:24 AM
Thank you for helping... it wasnt viewstat problem ..
I have solved...
ProfileCommon p;
protected void Page_Load(object sender, EventArgs e)
{
p = this.Profile;
if (!IsPostBack)
{
TextBox1.Text = p.status;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (Button1.Text == "Edit")
{
TextBox1.ReadOnly = false;
Button1.Text = "Update";
}
else if (Button1.Text == "Update")
{
TextBox1.ReadOnly = true;
p.status = TextBox1.Text;
Button1.Text = "Edit";
}
}
Lalit MPosted Feb 15, 2010, 1:00 AM
Amit ChoudharyPosted Feb 15, 2010, 12:34 AM
try set the page attribute in PageDirective EnableViewState=true;
if its not working in your case then do it for each control.
the reason behind this is because the HTTP protocol is stateless protocol as you fire postback or page refresh all states of variables are lost and they set to either null or their default value. so you have to save their state. And EnableViewState provide you this facility.
Please Kick it if it helps you.