UPDATE1
I tried with EnableViewState in Page directive: but no avail.
End
I am running as a usercontrol in sharepoint. (using SmartPart) Everything's fine. Just the Viewstate-Variables!
The usercontrol (also saving the variables in viewstate) works fine in a normal aspx-site. The issue is in a sharepoint environment it won't run. I checked the "enableViewState" is set to "true". So what can be wrong?
I am trying to extract the data(storing some text like Ids) from the ViewState but it does not seems to work and it just returns me a null value.
here is what i am doing:
UserControl Implementation (VisualWebPartControl1.cs):
WebPart Implementation (VisualWebPart1.cs)
I have created a visual web part (creates usercontrol.ascx and .cs file)
public partial class VisualWebPart1UserControl : UserControl
{
protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
{
string SetId = ddl.SelectedItem.Value;
this.ViewState[TabStorageViewStateId] = SetId;
}
}
WebPart Implementation (VisualWebPart1.cs)
public class VisualWebPart1 : WebPart
{
private const string _ascxPath = @"~/_CONTROLTEMPLATES/mypath/VisualWebPart1/VisualWebPart1UserControl.ascx";
protected override void CreateChildControls()
{
//generated by visual studio
//Control control = Page.LoadControl(_ascxPath);
//Controls.Add(control);
var control = (VisualWebPart1UserControl) Page.LoadControl(_ascxPath);
string retValue = this.ViewState[TabStorageViewStateId] as string;
}
}