Hello,
I am trying to set value to state aginst a button click and get a value from another button click. It is just shocking that I was unable to meet this reqirement when creating custom webpart.I have seen many people are getting issues with viewstate. Can you please look into the below code and please let me know how can I make this working. Here I am assigning values on btnNext button click and trying to get values on btnPrev button click. Please assist me. I am using Kentico version 7.0
public partial class Customwebpart: CMSAbstractWebPart
{
protected void btnPrev_Click(object sender, EventArgs e)
{
var viewstatevalue = ViewState["Step"] ; //getting null here
var requesthelpervalue = getWord();
}
protected void btnNext_Click(object sender, EventArgs e)
{
ViewState["Step"] = Convert.ToInt32( ViewState["Step"] )+ 2;
setWord("Hello");
}
public string setWord(object input)
{
string word = ValidationHelper.GetString(input, String.Empty);
CMS.GlobalHelper.RequestStockHelper.Add("value", word);
return "";
}
public string getWord()
{
string word = ValidationHelper.GetString(CMS.GlobalHelper.RequestStockHelper.GetItem("value"), String.Empty);
return word;
}
}