1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Viewstate Work-Around?

Viewstate Work-Around?

5 posts, 0 answered
  1. AFTR
    AFTR avatar
    22 posts
    Registered:
    05 Oct 2010
    10 Mar 2011
    Link to this post
    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
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    14 Mar 2011
    Link to this post
    Hello,

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

    Regards,
    Ivan Dimitrov
    the Telerik team
  3. Eric
    Eric avatar
    147 posts
    Registered:
    12 Nov 2007
    17 Mar 2011
    Link to this post
    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.
  4. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    19 Mar 2011
    Link to this post
    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
  5. Eric
    Eric avatar
    147 posts
    Registered:
    12 Nov 2007
    19 Mar 2011
    Link to this post
    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;
    }
5 posts, 0 answered