[CLOSED] [1.0] - MVC - ViewData binding to Portlet Visible not working

  1. #1

    [CLOSED] [1.0] - MVC - ViewData binding to Portlet Visible not working

    Hi,

    I am trying to hide a Portlet base on security. So, I have ViewData["isVisible"] = false, and when databind it to the Visible property for a Portlet, the page throw exception (error from FireBug is "invalid object initializer". But if I set the ViewData["isVisible"] = true, it works fine.


    View Code
    <ext:Portal ID="Portal2" runat="server" Border="false" Layout="Column">
        <Items>
            <ext:PortalColumn ID="PortalColumn3" runat="server" StyleSpec="padding:5px 5px 0px 5px" ColumnWidth=".5" Layout="Anchor" AutoScroll="true">
                <Items>
                    <ext:Portlet ID="Portlet1" runat="server" Height="512" BodyStyle="padding:0px 0px 0px 0px" Visible='<%# ViewData["RoleTradeSummaryRead"] %>' AutoDataBind="true">                    
                    </ext:Portlet>
                </Items>
            </ext:PortalColumn>
        </Items>
    </ext:Portal>
    Controller Code

    public ActionResult Dashboard()
    {
        ViewData["isVisible"] = false;
        return this.View();
    }
    Thanks.
  2. #2

    RE: [CLOSED] [1.0] - MVC - ViewData binding to Portlet Visible not working

    Hi,

    I cannot reproduce it. Please provide full test sample
  3. #3

    RE: [CLOSED] [1.0] - MVC - ViewData binding to Portlet Visible not working

    Hi,

    Is a bit difficult to strip my current project or create a test project for this issue.
    I wonder can you please post the test project you have?


    Thanks

  4. #4

    RE: [CLOSED] [1.0] - MVC - ViewData binding to Portlet Visible not working

    Hi,

    I tested Portlet with Visible="false" and it works correctly. Let me test with Visible='<%# ViewData["RoleTradeSummaryRead"] %>'...
  5. #5

    RE: [CLOSED] [1.0] - MVC - ViewData binding to Portlet Visible not working

    I would like to point out that in the sample I post, the markup code ViewData should be ViewData["isVisible"] instead of the ViewData["RoleTradeSummaryRead"], it was typo. thanks.
  6. #6

    RE: [CLOSED] [1.0] - MVC - ViewData binding to Portlet Visible not working

    Hi,

    Yes, it seems there is a problem. The issue: PortalColumn script generated early then Visible property of the portlet is binded because PortalColumn is rendered early then portlet.

    At this moment I can suggest only one solution: set Visible in the code behind instead code block
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Index</title>
        
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                Portlet1.Visible = (bool)ViewData["isVisible"];
            }
        </script>
    </head>
    <body>
        <ext:ResourceManager runat="server" InitScriptMode="Inline"/>
       <ext:Portal ID="Portal2" runat="server" Border="false" Layout="Column">
        <Items>
            <ext:PortalColumn ID="PortalColumn3" runat="server" StyleSpec="padding:5px 5px 0px 5px" ColumnWidth=".5" Layout="Anchor" AutoScroll="true">
                <Items>
                    <ext:Portlet ID="Portlet1" runat="server" Height="512" BodyStyle="padding:0px 0px 0px 0px">                    
                    </ext:Portlet>
                </Items>
            </ext:PortalColumn>
        </Items>
    </ext:Portal>
    </body>
    </html>
  7. #7

    RE: [CLOSED] [1.0] - MVC - ViewData binding to Portlet Visible not working

    ok, no problem. Thanks.

Similar Threads

  1. [CLOSED] visible in code behind doesn't work for portlet
    By CarpFisher in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Jun 29, 2012, 12:30 PM
  2. Replies: 1
    Last Post: Aug 23, 2011, 7:09 PM
  3. Replies: 0
    Last Post: Aug 21, 2011, 12:19 PM
  4. Replies: 2
    Last Post: Jul 31, 2011, 9:58 PM
  5. Replies: 5
    Last Post: Jun 03, 2009, 7:13 AM

Posting Permissions