Viewstate Work-Around?

Posted by Community Admin on 03-Aug-2018 16:21

Viewstate Work-Around?

All Replies

Posted by Community Admin on 10-Mar-2011 00:00

Hello,

I am aware of the viewstate issue and am wondering if there is a workaround of some type?

My requirements need me to create pages in Sitefinity (by whatever means) with both a horizontal menu across the top, and a vertical menu on the left.

In the main content pane is where I will put my custom user controls created in visual studio, but these will obviously need view state, so I can't use the layout mode in Sitefinity, and master pages won't work either.

Thanks

Posted by Community Admin on 14-Mar-2011 00:00

Hello,

You can try using session or cookies to get/set some values.

Regards,
Ivan Dimitrov
the Telerik team

Posted by Community Admin on 17-Mar-2011 00:00

Is this going to be fixed in Q1?

I databind a dropdown in the Page_Load event and when the Button_Click event fires, I don't have a value in the dropdown any more.

I suppose with some JavaScript I could add get this to work with cookies, but that'd be pretty clunky.

Posted by Community Admin on 19-Mar-2011 00:00

Hello Eric,

Yes, the view state will be fixed in Q1. 
On the other hand, you cannot persist dropdown values in a viewstate automatically even on a regular asp.net page. The drop down is a composite control with list items as child controls, so you should have a custom logic for persisting their values.

Best wishes,
Georgi
the Telerik team

Posted by Community Admin on 19-Mar-2011 00:00

I'll defer to you as the ASP.NET expert, but I have code something like this. On the button click event in a normal ASPX page, the dropdownlist has a selected value. On the button click event on a SF page, the dropdownlist has a selected value. On the button click event on a SF page where the control is inside a column layout, the dropdownlist has no selected value (or any values).

protected void Page_Load(object sender, EventArgs e) 
   if (!IsPostback)
     myDropDownList.DataSource = Enumerable.Range(0, 10);
     myDropDownList.DataBind();
    
 
protected void myButton_Click(object sender, EventArgs e) 
    myLabel.Text = "Your favorite number is " + myDropDownList.SelectedValue;

This thread is closed