Click here to Skip to main content
15,908,013 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
C#
protected void btnReq_Click(object sender, EventArgs e)
  {
      ViewState["lbl"] = "text Labal";

  }
  protected void btnRespo_Click(object sender, EventArgs e)
  {

          lblText.Text = ViewState["lbl"].ToString();

  }
Posted
Comments
CHill60 16-Mar-15 12:45pm    
In which line is the problem and under what circumstances does it happen?
Rajnish D mishra 16-Mar-15 12:46pm    
lblText.Text = ViewState["lbl"].ToString();
there error show when i click on button btnRespo

1 solution

It is obvious that ViewState["lbl"] is NULL!
You ask why - I can't say for sure, but the most common cause is that your buttons are doing full-page-postback and while there resetting ViewState...
Wrap you clicks in UpdatePanel ot force them to do partial-postback...
This article may give you a start: http://ajax.net-tutorials.com/controls/updatepanel-control/[^]
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 16-Mar-15 14:21pm    
5ed... :-)
—SA
Kornfeld Eliyahu Peter 16-Mar-15 15:30pm    
Thank you...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900