No Viewstate

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

No Viewstate

All Replies

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

I know this has been covered before, but the proposed solution does not work for me.

On postbacks, I'm losing the values in my dropdown lists (and other things I set in the Page_Load event when the page is first loaded). Below is an example (I'm getting values from a DB) of what I'm doing. The Page_Load event is in a custom control. The OnInit override is in my MasterPage (template). If I look at the IsViewStateEnabled or EnableViewState properties, they look good.

I've also tried setting ViewStateMode in the MasterPage and control to "Enabled" with no luck.

protected void Page_Load(object sender, EventArgs e)
    if (!IsPostBack)
    
        ddlNumbers.DataSource = Enumerable.Range(1, 10);
        ddlNumbers.DataBind();
    
 
protected override void OnInit(EventArgs e)
    Page.EnableViewState = true;
    base.OnInit(e);

Any suggestions?

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

Hi Eric,

You might find this post useful.

Kind regards,
Ivan Dimitrov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

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

This seems to be all about backend pages (which I assume are the pages under the /Sitefinity folder). I'm not worried about those. I'm struggling getting the frontend pages (e.g. my homepage) to maintain their values in the viewstate. Everybody seems to say the line "Page.EnableViewState = true" works for them, but for me it's not.

I added in some testing code just to test out the ViewState. I check to see if there's a "Now" value in the ViewState, if there isn't, I put the current time into the ViewState. I then output the value. On the initial load, it prints the current time. When my custom control does a postback, a new time gets outputted, which makes me think the ViewState isn't working.

protected override void OnInit(EventArgs e)
    Page.EnableViewState = true;
 
    if (ViewState["Now"] == null)
    
        ViewState["Now"] = DateTime.Now.ToLongTimeString();
    
 
    Response.Write(ViewState["Now"]);
 
    base.OnInit(e);

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

Hi Eric,

I'm having the exact same issue with my implementation and I tried turning the ViewState on in 3 locations...web.config, the page itself, and the actual control. None of the options worked for me either.

Posted by Community Admin on 11-Jan-2011 00:00

Yeah, I tried the web.config, the page directive of the master page, the control directive of the user control, overriding the OnInit event of the master page, overriding the OnInit event of the user control.

It's working for other people?

Posted by Community Admin on 11-Jan-2011 00:00

Hello Eric,

This is a master page that worked for me. Hopefully, it helps.

John

<%@ Master Language="C#" AutoEventWireup="true" %>
<script type="text/C#" runat="server">
    protected override void OnInit(EventArgs e)
    
        this.Page.EnableViewState = true;
        base.OnInit(e);
    
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head runat="server">
    <title></title>
<style type="text/css">  
    html, body, form  
      
        height: 100%;  
        margin: 0px;  
        padding: 0px;  
        overflow: hidden;  
      
    </style
       </head>
<body>
    <form runat="server">
<asp:ContentPlaceHolder ID="PageMenu" runat="server"></asp:ContentPlaceHolder>
            <asp:ContentPlaceHolder ID="MainContent" runat="server"/>
    </form>
</body>
</html>


Posted by Community Admin on 11-Jan-2011 00:00

Hello John,

Thanks for your input here.

For the official release there will be an option to enable the ViewState for each page from the UI, so I believe that nobody will have issues with this.

Greetings,
Ivan Dimitrov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 11-Jan-2011 00:00

Hey John,

Thanks for sharing that code...that's working for me on most pages now and will do until the final release of 4.0.

The only thing I haven't got it to work for is drag and drop between 2 RadGrids.

Posted by Community Admin on 11-Jan-2011 00:00

So I looked at the HTML source of the page and the ViewState is there. Decoding it showed the values I was expecting.

But my databound controls (e.g. dropdown lists and repeaters) still lose their values. Again, the EnableViewState = true in the init event didn't do anything. Will the page property still fix my issue since the ViewState seems to be working; it's working, but my controls aren't getting values from the ViewState.

In a standard web application with ASPX pages, it works fine.

Thanks,
Eric

Posted by Community Admin on 11-Jan-2011 00:00

OK, I think I figured it out. The ViewState is working, but when I put a control in a Layout control, my databound controls lose their values after a postback.

I have a base template based on a masterpage. If I put my control in the template directly, it works. If I add a layout control and put my control inside the layout, it doesn't work.

I tried to fix it by having my control set its parent's viewstate property (and it's parent's parent and it's parent's parent's parent, etc) which didn't fix it. I also tried to have my master page recursively set it and its child controls to enable the viewstate; again no luck. I also tried to set enable_view_state = 1 on my master page in the sf_page_templates table, again nothing. I then set enable_view_state on sf_page_data and again nothing.

I wonder how these layouts work and how they interfere with the controls.

Hopefully the discussed option to set the ViewState per page fixes this issue or this is fixed for the official release.

Posted by Community Admin on 11-Jan-2011 00:00

Eric,

I concur with your findings. The drag and drop table that I couldn't get to work after applying the master page fix that John posted is in a layout template that divides the page into 25% / 75% columns.

Posted by Community Admin on 21-Jan-2011 00:00

Hi Eric,

We've reproduced the issue at was logged as a bug (#105496). We'll try to fix it for SP1. I am sorry for the inconvenience that this might have caused you.

Regards,
Pavel
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 24-Jan-2011 00:00

I have a control which requires ViewState.
I have put this control into the Sitefinity toolbox.
I have created a page and added the control from the toolbox to it.
My controls lose their values on postbacks. (I have tried the suggestion of using my own master page and called EnableViweState = true. This does not prevent me from losing values.)

The previous post mentions a bug. I don't know if that bug is relevant to my problem or not.

Please, Telerik, tell me, am I able to use ViewState for a control I've created and added to the toolbox, or not?
If the answer is yes, please tell me precisely how to do it.

Thank you.

Posted by Community Admin on 25-Jan-2011 00:00

Hi Eric,

We are investigating the issue and I hope that it will be fixed in one of the next internal builds that we have each Friday.
Currently you can get the ViewState workign if you declare the controls inside your .master file, but this means that you cannot edit them through Sitefinity's page editor.

All the best,
Ivan Dimitrov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 25-Jan-2011 00:00

Hi,

I have the same problem. If i drag and drop to master page it works if i drag and drop to one custom layout my control loses the viewstate.

But another strange thing happens. If i drag one "Content block" before my control de viewstate of my control starts to work. If i remove the "control block" the viewstate fail again.

I hope this be resolved soon.

Posted by Community Admin on 25-Jan-2011 00:00

Hello,

Yes the team is working on this issue. It is with high priority and I hope that we will manage to fix it by the end of the week.

Best wishes,
Ivan Dimitrov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

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

I have a front-end page for which I checked the "Enable ViewState" checkbox.

However, ViewState is not working on that page. (Or more specifically, on my controls that are on that page.)

I am using version 4.0.1098.0

Please, can you tell me if this is still a problem that has not been fixed. Or can you please tell me what to do to simply enable ViewState on my front-end page.

(I am extremely frustrated by this. I don't know why something this simple and this common is so hard to get working.)

Thank you.

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

Hello,

We keep working on the issue. Its current status is not done. It turned out that the fix is not something trivial and we will need more time to sort out the problem properly.

Greetings,
Ivan Dimitrov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

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

I had this same problem today and found a work around that works for my case - maybe yours too.
 
In my case, my pages use a Master Page file as a template (I'm migrating existing design from SF 3.7 and not using layout controls at all).

Enabling ViewState on my master page fixed this issue for me.

<%@ Master Language="C#" EnableViewState="true" %>

Hope this helps some until a fix is released.

Posted by Community Admin on 24-Feb-2011 00:00

Unfortunately, the master page fix doesn't work for me.

Posted by Community Admin on 24-Feb-2011 00:00

Are you using templates (i.e. column templates)? I don't think there's a workaround for controls in the templates. If you take your control out of a template, the workarounds should work -- at least mine does.

Posted by Community Admin on 24-Feb-2011 00:00

I create a new page and for its template I select my own master page. Then I put my user control onto this page. The ViewState doesn't work.

I can only get ViewState to work when I create my own aspx page. 

Posted by Community Admin on 24-Feb-2011 00:00

Hi Eric,

The issue with the View State is still not fixed. We keep working on it.

Best wishes,
Ivan Dimitrov
the Telerik team

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

Hello Ivan,

It's been a week since the last post, and Sitefinity 4.0 SP1 has come and gone and there is still no resolution.

Can you provide an update on the progress regarding this issue? 

This issue is also suspiciously missing from PITS.

Thanks, Greg

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

I'd like to add my voice to this. 

Not being able to use Viewstate from Page_Load has turned into a huge issue for us, potentially requiring a lot of kludgey workarounds.

Ivan, if you could please let us know if this is fixed in a weekly build, or if it's scheduled for Q1, it would help all of us schedule development and possibly discuss this with our clients.

Thanks.

- William

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

Hello William,

The fix should be available in Q1 release. I agree that this is really frustrating and we are doing our best to fix the problem ASAP. We are changing some basic code related to the page lifecycle and this is quite difficult. I will update the post if the issue is fixed before the Q1 release, so you ca get an internal build. I am sorry for the inconvenience.

Regards,
Ivan Dimitrov
the Telerik team

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

Ivan,

Can you at least add this issue into PITS?  I'd rather see it tracked there, then here in this forum post.

Do I need to open a ticket to get it there?  I have to believe that there a boatload of other customers that already have tickets open for this issue.

Thanks, Greg

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

Hi Greg ,

The issue is logged with ID 4968 - RadGrid problem with the life cycle on postback

All the best,
Ivan Dimitrov
the Telerik team

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

What about the original issue in the thread? No viewstate (until PreRender I think) when controls are in (column) layouts?

Is that in PITS? Should I go add it?

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

You've logged this as a RadGrid problem?

Isn't this a general ViewState problem?

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

Hi Ivan,

Yes, I saw that issue, and thought it might be related, however, #4968 reads as a RadGrid problem in Sitefinity.

While I agree I'm sure the Viewstate issue is causing that problem among others, that issue does not directly reflect the underlying problem.   The real problem here is the Viewstate, not Radgrid, not Ajax, not anything else.

The ticket should reflect the underlying problem, in my opinion, and perhaps note the issues related to the problem.

Thanks, Greg

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

Hi everyone, 

I was wondering since this caused lot of problems because ViewState is used almost everywhere. 
How did we get to this : for a basic functionality the basic Control tests would fail and I think you Telerik guys ran into having a release for 2011 but you shouldn't release stuff like this.
Now we have problems with our clients  
We tested SF for previous release and this seemed working,
Even we had other problems, we could have some work around and we could going on.

But when it comes to ViewState not working, this is quite serious and frustrating. 

I hope this get fixed because this stopped us. 

I am working not on a ASP web Application and I will use  with RadControls (for test purposes) hoping 
I can integrate my UC then in SF.


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

Hi,

We are fixing this with high priority, and will definitely have a fix for it in for the Q1 release. We can also push the fix as an internal build, if you would like us to do it.

All the best,
Georgi
the Telerik team

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

I'm pretty sure that you would update this thread, if there was a solution available, but just in case...

I'm trying to make a case for using SiteFinity in a large development project that's just getting underway, and the main objection is finding ourselves unable to deliver because of a serious SiteFinity bug with no work-around. I was dismayed to chance across this problem, a case-in-point.

So, any good news? ETA? Anything? Is the problem well-understood? Is it fixed in 50% of SF? 80%?

Thanks, Hoyt

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

Hi Greg Figueroa,

the bug has been fixed indeed and is in process of extended testing. Yes, we know we should have done this way, way earlier, but there is really nothing else we can do except offer sincere apology.

We have moved completely to the Virtual Path Provider, which means that Sitefinity pages will now behave exactly as any other ASP.NET page. Apart from the obvious functional benefits (exact lifecycle), this also brings about a significant performance improvement.

The fix will be made available in Sitefinity 2011 Q1, which is due on April 13th.

Once again, to you and all other affected, we are really sorry about this problem and that it took us so long to fix it.

Best wishes,
Ivan
the Telerik team

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

Hi,

Is this bug can't be release in any of the internal builds before April 13th?
Cause we have to release our project during this week, and we can't release with this issue.

Thanks.

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

Hi AmrElsayed,

Thanks for the follow up.

Can you please let us know what exactly stops you to go to production? If you have worked it around in development, this should not stop you for production? 

Greetings,
Georgi
the Telerik team

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

Hi Georgi,

We have several controls that rely heavily on viewstate and it's getting lost between requests, our work is complete and is working fine in normal asp.net websites but once the user controls are moved into the sitefinity runtime, viewstate disappears across postbacks, this is explained below in the thread, I don't want to repeat the same requests other developers have raised, I am just asking if any of the latest internal builds contain the fix so we can check it out.

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

Hi Georgi,

That's great news.  I'd love to get my hands on it sooner, but I am happy that there is a definative date now set.  Looking forward to eliminating my temporary aspx pages that emulate what Sitefinity does.

Thanks again,

Greg

Posted by Community Admin on 13-Apr-2011 00:00

...Chomping at the bit to get my hands on Sitefinity 4.1.  The ads are up, and the webinar scheduled.  The 13th of April has arrived, but the download is still not posted...  

Are we going to get our hands on it today?

Thanks, Greg

Posted by Community Admin on 15-Apr-2011 00:00

Hi Greg Figueroa,

We are having an official statement here - http://www.sitefinity.com/devnet/forums/sitefinity-4-x/general-discussions/sitefinity-2011-q1-postponed-by-one-week.aspx

Greetings,
Georgi
the Telerik team

Posted by Community Admin on 18-Apr-2011 00:00

Disregard

Posted by Community Admin on 09-Dec-2011 00:00

Telerik,

We're using Sitefinity 4.2.1650 and the ViewState issue is still not fixed.  
I have enabled ViewState per page; however, my user controls are still losing values on postback.
I have written my own custom user controls and added them to my own custom templates.  I've combed
the forums looking for solutions and have tried the OnInit to enable viewstate for the page and
it's not working.  Is this fixed in a build after 4.2.1650?  Please advise.

Mark 

Posted by Community Admin on 13-Dec-2011 00:00

Hi Mark,

I can confirm we used to have issue with the Enable Viewstate option for pages not taking effect, however these were fixed for our Sitefinity 4.2 release, and since then up to my knowledge you're the first to report such behavior. Would it be possible to give us a sample user control you're testing with, so we can test if the issue will reproduce with it, as we were unable to reproduce it on several Sitefinity 4.2 and 4.3 projects. Looking forwards to your reply.

All the best,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

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

Hi Boyan,

We too are using 4.2.1650 and have an issue with viewstate, but only for "list" controls.  
The workaround we are currently using is to read the values from the Request on Page_Load (e.g.  
lstControl.SelectedValue = Request.Form(this.FindControl("lstControl").UniqueID)   )

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

Hello Moot,

Can you please paste/send us a copy of your ~/App_Data/Sitefinity/Configurations/SystemConfig.config file, and a copy of the ~/App_Data/Sitefinity/Logs folder so we can check if there's anything that might be causing these problems.

Regards,
Boyan Barnev
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

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

Boyan,

Here is the config file.  How do you want me to send the Zip of the Logs folder (give me an Email address or ?).  Just an FYI, we have this issue in the CoursesModule in config below as well as some ascx/vb controls.  

Thanks,
Moot

<?xml version="1.0" encoding="utf-8"?>
<systemConfig xmlns:config="urn:telerik:sitefinity:configuration" xmlns:type="urn:telerik:sitefinity:configuration:type" config:version="4.2.1650.0" build="1650" previousBuild="1574">
 <servicesModules>
  <add version="4.2.1650.0" name="Search" />
 </servicesModules>
 <applicationModules>
  <add version="4.2.1650.0" name="News" />
  <add version="4.2.1650.0" name="Blogs" />
  <add version="4.2.1650.0" name="Events" />
  <add version="4.2.1650.0" name="Libraries" />
  <add version="4.2.1650.0" name="Forms" />
  <add version="4.2.1650.0" name="Lists" />
  <add version="4.2.1650.0" name="Analytics" />
  <add version="4.2.1650.0" name="Publishing" />
  <add version="4.2.1650.0" name="Scheduling" />
  <add version="4.2.1650.0" name="Newsletters" />
  <add version="4.2.1650.0" name="GenericContent" />
  <add version="4.2.1650.0" name="ControlTemplates" />
  <add version="4.2.1650.0" name="Migration" />
  <add version="4.2.1650.0" name="Catalog" />
  <add version="4.2.1650.0" name="Orders" />
  <add version="4.2.1650.0" name="Shipping" />
  <add title="Courses" description="Courses" type="SitefinityWebApp.Modules.Courses.CoursesModule" startupType="OnApplicationStart" version="4.2.1733.0" name="Courses" />
 </applicationModules>
 <outputCacheSettings enableOutputCache="False" enableClientCache="False" />
</systemConfig>

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

Hi Moot,

If possible we would like also the code for your module and the .ascx/vb files. If the archive becomes too large you could create a password protected file, upload it to some free sharing service site like http://www.megaupload.com/ , give here the link to the file and send the password to the archive to Liubomir.Velkov@telerik.com

Kind regards,
Lubomir Velkov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

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

Lubomir,

I have sent a ZIP file to your email with some of the code that I hope will be enough for you to detemine if it is something we are doing wrong or if it is an issue with ViewState not being properly handled.

Thanks,
Moot

Posted by Community Admin on 21-Dec-2011 00:00

Hello Moot,

Unfortunately I didn't receive any email from your. Could you try opening a bug report and attach the code there?

Regards,
Lubomir Velkov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 21-Dec-2011 00:00

Sometimes I encounter problems when enabling viewstate after the page has been created. You might try enabling view state from the advanced options at the same time you create the page. This has always worked for me.

Posted by Community Admin on 22-Dec-2011 00:00

Hi,

I believe that the Moot's issue comes from the code that he use. We are looking for his ticket to see what exactly goes wrong.

All the best,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 11-Jan-2012 00:00

Ivan/Lubomir,

I will try to create a simple project that illustrates the problem and upload it to a ticket.  Have a looming deadline so I won't be able to take the time to get the example done for a few weeks.

Thanks,
Helmut

Posted by Community Admin on 10-Aug-2012 00:00

Is there any resolution to this?  I am running SItefinity 5.1 and am still seeing the exact behavior described throughout this thread.  I have a widget (user control) which contains a drop-down list that is populated at page load.  On post-back the list is not repopulated.  ViewState is enabled for the page and I can see the viewstate information when doing a "view source". 
Additionally, I am manually setting viewstate values within page_load and those disappear after postback as well.
The control is in a template column (not using a physical master page.)  If this was fixed in 4.2, WHY is it still happening in 5.1?

Posted by Community Admin on 10-Aug-2012 00:00

Is there any resolution to this?  I am running SItefinity 5.1 and am still seeing the exact behavior described throughout this thread.  I have a widget (user control) which contains a drop-down list that is populated at page load.  On post-back the list is not repopulated.  ViewState is enabled for the page and I can see the viewstate information when doing a "view source". 
Additionally, I am manually setting viewstate values within page_load and those disappear after postback as well.
The control is in a template column (not using a physical master page.)  If this was fixed in 4.2, WHY is it still happening in 5.1?

Posted by Community Admin on 10-Sep-2013 00:00

Bump, I'm encountering the same issue in 6.1, the page life cycle events are inconsistent and I have viewstate enabled on the page properties in Sitefinity. I'm just trying to bind a repeater on a button click. Anyone gotten this work and could share their code?

Posted by Community Admin on 13-Sep-2013 00:00

Hello all,

The bug reported in this thread is indeed fixed. My conclusion is that the issue lies in your code as we do not have any complaints of the ViewState recently. You can post your code here in the thread or better yet in a Sitefinity support ticket so the issue can be resolved.

Regards,
Ivan D. Dimitrov
Telerik

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed