Backend Viewstate

Posted by Community Admin on 03-Aug-2018 12:37

Backend Viewstate

All Replies

Posted by Community Admin on 09-Nov-2010 00:00

Hi,

I'm developing one backend custom module and i can't get Viewstate["key"] value after postback. In debug the this.Page.EnableViewstate is false. How can i enable it.

In frontend i put :

protected override void OnInit(EventArgs e)
    this.Page.EnableViewState = true;
    base.OnInit(e);


in the master page i develop.

How can i override the backend EnableViewState.

Posted by Community Admin on 09-Nov-2010 00:00

Hello JV,

The PageElement which you should use to create backend pages has a property EnableViewState that you can set to true. The default value is false.

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 09-Nov-2010 00:00

Hi,

I am new at sitefinity and I'm developping a backend simple "hello World" user control (.ascx) with a asp button but when using the button after drag the control to the page a fall in this error:

Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
 
After a few attemps, I found that it works in page preview mode.

this is my button at .ascx file.
<asp:LinkButton ID="BtAdd" runat="server" onclick="BtAdd_Click">add</asp:LinkButton>

 Best regards,

Posted by Community Admin on 09-Nov-2010 00:00

Hi Paulo,

The problem is that you have clicked the button when you are working in edit mode. You can hide the button while working in edit mode by using this.IsDesignMode() extension or cancel all navigation or post backs.
We have logged a bug for this issue and hopefully it will be resolved for the RC release.

canceling the click

protected void Page_Load(object sender, EventArgs e)
    if(this.IsDesignMode())
    
        this.button.OnClientClick = "return false;";
    


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 17-Dec-2010 00:00

Ivan,


I am having trouble with ViewState on an admin page that I created also. I tried setting the EnableViewState = true on the PageData instance when creating an admin page for my module during module installation.

However, it seems that I still do not have ViewState enabled for the page.

Can you please provide very specific instructions / samples / code that I can use in order to simply enable ViewState for my controls on an admin page I create for my custom module?

Thank you!

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

Hello Lorne,

In the RC you should use PageDataElement which has a public property EnableViewState. Inside InstallPages method in the custom module you can set the EnableViewState to true

sample

protected override void InstallPages(SiteInitializer initializer)
       
           var pageManager = initializer.PageManager;
           var moduleNode = pageManager.GetPageNode(SiteInitializer.ModulesNodeId);
           var id = ModulePageGroupId;
           var myNode = pageManager.GetPageNodes().Where(t => t.Id == id).SingleOrDefault();
           if (myNode == null)
           
               myNode = initializer.CreatePageNode(ModulePageGroupId, moduleNode);
               myNode.Name = "test";
               myNode.ShowInNavigation = true;
               myNode.Attributes["ModuleName"] = myModule.ModuleName;
               Res.SetLstring(myNode.Title, ResourceClassId, "PageGroupNodeTitle");
               Res.SetLstring(myNode.UrlName, ResourceClassId, "PageGroupNodeTitle");
               Res.SetLstring(myNode.Description, ResourceClassId, "PageGroupNodeDescription");
           
            
           id = this.LandingPageId;
           var landingPage =
               pageManager
               .GetPageNodes()
               .SingleOrDefault(p => p.Id == id);
           if (landingPage == null)
           
               var pageInfo = new PageDataElement()
               
                   PageId = this.LandingPageId,
                   Name = "myNode",
                   MenuName = "myNodeTitle",
                   UrlName = "myNodeUrlName",
                   Description = "myNodeDescription",
                   HtmlTitle = "myNodeHtmlTitle",
                   ResourceClassId = ResourceClassId,
                   IncludeScriptManager = true,
                   ShowInNavigation = false,
                   EnableViewState = true,
                   TemplateName = SiteInitializer.BackendTemplateName
               ;
            ....
              ......
           
 
       


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 04-Jan-2011 00:00

Ivan,

Thanks for the code.

I don't see a method called InstallPages(...). I do see Install(...), which I used.

Your code is very incomplete. What do I do with the PageDataElement that is instantiated?

Here is a snippet of code I was using:

var sf = App.WorkWith();
...
sf.Page().CreateNewStandardPage(LandingPageId, SubPageId).Do(p =>
                    
                        p.Page.EnableViewState = true;
                        p.Name = "MY NAME";
                        p.UrlName = "MY NAME";
                        p.Description = "";
                        p.ShowInNavigation = false;
                        p.Attributes["ModuleName"] =  "MY MODULE";
                    )
...

p, however, is not a PageDataElement, but rather a PageNode.

In any case, the ViewState does not work for me.

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

Hello Lorne,

This is a sample code, it is not entire implementation and there is a mark "sample" before the code block.
About 2 moths ago we made a refarctoring inside SiteInitializer method and InstallPages method and
PageDataElement which represents configuration element for a page exists on 100 %. Most probably you are using an old version rather than RC2.

We are working on a sample project - module that will be shipped as a part of the SDK with the official release. The module will show you how to create backend pages, controls, custom types etc.

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 04-Jan-2011 00:00

Ivan,

Which class has the InstallPages(...) method?

Thanks.

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

Hello,

InstallPages is an abstract method of ContentModuleBase(Represents generic content module.)
There is a base class which has two methods related to the installation - one of then is abstracted
public abstract void Install(SiteInitializer initializer); and the other one is virtual
 virtual void Initialize(ModuleSettings settings)

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 04-Jan-2011 00:00

Okay. I am subclassing from ModuleBase, which is why I did not see that method. (I assume I should continue subclassing ModuleBase if my module does not deal with "content".)

However, my problem remains: I still need a simple way of enabling ViewState on my admin page.

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

Hello,

I am not able to replicate an issue with the ViewState in the latest build. The view state mode could be tested with a simple code

var man = PageManager.GetManager();
          var pnds = man.GetPageNodes().Where(p => p.Title == "MyBackendPage").ToList();
          foreach (var pn in pnds)
          
              if (pn.Page != null && pn.IsBackend)
              
                  pn.Page.EnableViewState = true;
                  man.SaveChanges();
 
              
 
          

For the official release we are going to provide UI that will allow you to set the ViewState for each front end and backend page.

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 30-Mar-2012 00:00

I am getting a kinda the same problem. The only difference is that I'm working on a control with its own control designer template. I need to be able to save data to my viewstate during design mode. Was this issue resolved in SiteFinity 5? That's the version we're currently using.

Posted by Community Admin on 30-Mar-2012 00:00

I am getting a kinda the same problem. The only difference is that I'm working on a control with its own control designer template. I need to be able to save data to my viewstate during design mode. Was this issue resolved in SiteFinity 5? That's the version we're currently using.

This thread is closed