locked
Custom ASPX page and control states RRS feed

  • Question

  • Hi

    I am currently attempting to implement a custom ASPX page that contains a tree view and an iFrame. The idea is that when the user selects a node from the treeview the content of the iFrame changes according to the selection. I managed to get this working fine as a standalone page. However when I make it an item on the site map of CRM I have run in to a number of problems.

    The first problem I had was that when I clicked an item, the treeview nodes were lost and the event was not fired, therefore not changing the iFrame contents.

    I got around this my removing an if clause I had put in Page_Load so that the tree nodes were only built upon the initial connection and not on postbacks. Although this fired the event and retained the nodes, all the nodes would collapse every time which would not be a great user experience. I had this problem earlier in the standalone version and had fixed it by setting the "PopulateNodesFromClient" to false. However this seems to have no effect when running within CRM.

    Getting a little desperate I tried saving the nodes in the session state. This worked in the standalone version, but within CRM the session state is null and so an exception is thrown when trying to save it. I have enabled session and view states within my web.config and this is done within the Page_Load function. Searching around the internet it has been suggested to make any extensions "stateless" like CRM itself and I would prefer to do so however I have not been able to achieve what I would like.

    The basic requirements are -

    • When clicking on an item, the event is fired and the iFrame content changes
    • When posting back, the tree view should retain its expanded/collapsed states
    • Where possible retain best practice for developing in CRM

    That's a long post but your help would be much appreciated!!

    Thanks

    Zak

     

    Thursday, November 11, 2010 9:58 AM

Answers

  • Hi,

    This is a common issue during custom aspx development. Since CRM is a stateless application, viewstate is not enabled in its web.config. If your application's web.confg does not specify enableviewstate="true", your page will not be able to work with viewstates.

    To solve this, either enforce enableviewstate="true" in your web.config file or specify the setting in your aspx page like below:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" EnableViewState="true" Inherits="Custom._Default" %>
    
    • Proposed as answer by pogo69 Thursday, November 11, 2010 10:44 PM
    • Marked as answer by zak_nye Tuesday, November 16, 2010 10:21 AM
    Thursday, November 11, 2010 10:06 AM

All replies

  • Hi,

    This is a common issue during custom aspx development. Since CRM is a stateless application, viewstate is not enabled in its web.config. If your application's web.confg does not specify enableviewstate="true", your page will not be able to work with viewstates.

    To solve this, either enforce enableviewstate="true" in your web.config file or specify the setting in your aspx page like below:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" EnableViewState="true" Inherits="Custom._Default" %>
    
    • Proposed as answer by pogo69 Thursday, November 11, 2010 10:44 PM
    • Marked as answer by zak_nye Tuesday, November 16, 2010 10:21 AM
    Thursday, November 11, 2010 10:06 AM
  • Thanks Danny

    I had already set the web.config to enable view state but had not done it at the top of my aspx page like you suggested. When I did this it worked.

    Zak

    Tuesday, November 16, 2010 10:22 AM