Results 1 to 8 of 8

Thread: [CLOSED] [1.0] MenuItem Click DirectEvent

  1. #1
    Member methode's Avatar
    Join Date
    Oct 2008
    Location
    ITALY
    Posts
    427

    [CLOSED] [1.0] MenuItem Click DirectEvent

    Hi,

    I have a problem with the following code. It worked well with 0.8.2.

    It is context menu attached to TreePanel. When I click on a MenuItem it gives me "Request Failure", status code 500.

    Code:
    ->TreePanel
    
    ...
    
    <Listeners>
     <ContextMenu Handler="#{cmenu}.node = node; node.select(); #{cmenu}.showAt(e.getPoint());" />
    </Listeners>
    
    ->Context Menu
    
    <ext:MenuItem ID="mnDisAbilita" runat="server" Text="disabilita voce di menu" Icon="ApplicationOsxDelete">
                    <DirectEvents>
                        <Click OnEvent="MB_Deny_Click">
                            <ExtraParams>
                                <ext:Parameter Mode="Value" Name="prmNodeIdDeny" Value="={#{cmenu}.node.id}">
                                </ext:Parameter>
                            </ExtraParams>
                        </Click>
                    </DirectEvents>
                </ext:MenuItem>
    
    ->Code
    
    protected void MB_Deny_Click(object sender, DirectEventArgs e)
    {
                string _id = e.ExtraParams["prmNodeIdDeny"].ToString();
                if (_id == "0") return; 
                ...
    }
    ViewState is enabled.

    Do I have to change code?

    Thanx

    Matteo

  2. #2
    Ext.NET - Dev Team Vladimir's Avatar
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    15,357

    RE: [CLOSED] [1.0] MenuItem Click DirectEvent

    Hi,

    I am sure that status code 500 is consequence of server side exception. Try to set breakpoint inside MB_Deny_Click. Do you reach it?


    Please create simple example which reproduces the problem
    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  3. #3
    Member methode's Avatar
    Join Date
    Oct 2008
    Location
    ITALY
    Posts
    427

    RE: [CLOSED] [1.0] MenuItem Click DirectEvent

    Hi Vlad,

    no, I tried it, but it didn't reach server side code.

    I'll prepare a simple example and post it.

    Matteo

  4. #4
    Ext.NET - Dev Team Vladimir's Avatar
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    15,357

    RE: [CLOSED] [1.0] MenuItem Click DirectEvent

    Hi,

    You can press Alt-Ctrl-E in VS to catch all exception (check checkbox for Common Language Runtime Exceptions). Then VS will show where exceptions occur
    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  5. #5
    Member methode's Avatar
    Join Date
    Oct 2008
    Location
    ITALY
    Posts
    427

    RE: [CLOSED] [1.0] MenuItem Click DirectEvent

    Hi Vlad,

    I reproduced the error, the event stopped before entering server side code!?

    However it was my fault, I decided to print in red the resource - treenode - not enabled.

    To do this I added a tag to the node text.

    In the code below, if you remove the tag it works fine.

    Can you suggest an error safe solution to render the text node colored?

    Code:
    <%@ Page Language="C#" %>
    
    <%@ 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>TreePanel with Async TreeLoader using Page - Ext.NET Examples</title>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" />
    
        <script runat="server">
            protected void NodeLoad(object sender, NodeLoadEventArgs e)
            {
                string prefix = e.ExtraParams["prefix"] ?? "";
    
                if (!string.IsNullOrEmpty(e.NodeID))
                {
                    for (int i = 1; i < 6; i++)
                    {
                        AsyncTreeNode asyncNode = new AsyncTreeNode();
                        asyncNode.Text = prefix + e.NodeID + i;
                        asyncNode.NodeID = e.NodeID + i;
                        e.Nodes.Add(asyncNode);
                    }
    
                    for (int i = 6; i < 11; i++)
                    {
                        Ext.Net.TreeNode treeNode = new Ext.Net.TreeNode();
                        //treeNode.Text = prefix + e.NodeID + i;
    
                        // It causes the error
                        //
                        treeNode.Text = "" + prefix + e.NodeID + i + ""; 
                        //
                        
                        treeNode.NodeID = e.NodeID + i;
                        treeNode.Leaf = true;
                        e.Nodes.Add(treeNode);
                    }
                }
            }
    
            protected void MB_Deny_Click(object sender, DirectEventArgs e)
            {
                string _id = e.ExtraParams["prmNodeIdDeny"].ToString();
                this.TextField2.Text = "Deny Node: " + _id.ToString();
            }
    
    
            protected void MB_Accept_Click(object sender, DirectEventArgs e)
            {
                string _id = e.ExtraParams["prmNodeIdAccept"].ToString();
                this.TextField2.Text = "Allow Node: " + _id.ToString();
            }
            
        </script>
    
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" EnableViewState="true" />
        <ext:Viewport ID="ViewPort1" runat="server">
            <Content>
                <ext:BorderLayout ID="CL_BorderLayout" runat="server">
                    <North>
                        <ext:Panel runat="server" ID="Panel1">
                            <Content>
                                
                            </Content>
                        </ext:Panel>
                    </North>
                    <West CollapseMode="Mini" Split="true" Collapsible="true" MaxWidth="400" MinWidth="180">
                        <ext:Panel ID="CL_WestPanel" runat="server" Title="Menu" Width="200"
                            BodyBorder="false" BodyStyle="margin:0px;" Layout="Accordion">
                            <Items>
                                <ext:TreePanel ID="TreePanel1" runat="server" Title="Tree" AutoHeight="true" Border="false">
                                    <Loader>
                                        <ext:PageTreeLoader OnNodeLoad="NodeLoad">
                                            <BaseParams>
                                                <ext:Parameter Name="prefix" Value="#{TextField1}.getValue()" Mode="Raw" />
                                            </BaseParams>
                                        </ext:PageTreeLoader>
                                    </Loader>
                                    <Listeners>
                                        <ContextMenu Handler="#{cmenu}.node = node; node.select(); #{cmenu}.showAt(e.getPoint());" />
                                    </Listeners>
                                    <Root>
                                        <ext:AsyncTreeNode NodeID="0" Text="Root" />
                                    </Root>
                                </ext:TreePanel>
                            </Items>
                        </ext:Panel>
                    </West>
                    <Center>
                        <ext:Panel runat="server" ID="TST">
                            <Content>
                                
                                <h1>
                                    TreePanel using PageTreeLoader</h1>
                                <p>
                                    Set custom node prefix:
                                </p>
                                <ext:TextField ID="TextField1" runat="server" Text="Node" />
                                <p>
                                    Menu Item click:
                                </p>
                                <ext:TextField ID="TextField2" runat="server" Text="" />
                                
                            </Content>
                        </ext:Panel>
                    </Center>
                </ext:BorderLayout>
            </Content>
        </ext:Viewport>
        <ext:Menu ID="cmenu" runat="server">
            <Items>
                <ext:MenuItem ID="mnDisAbilita" runat="server" Text="deny" Icon="ApplicationOsxDelete">
                    <DirectEvents>
                        <Click OnEvent="MB_Deny_Click">
                            <ExtraParams>
                                <ext:Parameter Mode="Value" Name="prmNodeIdDeny" Value="={#{cmenu}.node.id}">
                                </ext:Parameter>
                            </ExtraParams>
                        </Click>
                    </DirectEvents>
                </ext:MenuItem>
                <ext:MenuItem ID="mnAbilita" runat="server" Text="allow" Icon="ApplicationOsxStart">
                    <DirectEvents>
                        <Click OnEvent="MB_Accept_Click">
                            <ExtraParams>
                                <ext:Parameter Mode="Value" Name="prmNodeIdAccept" Value="={#{cmenu}.node.id}">
                                </ext:Parameter>
                            </ExtraParams>
                        </Click>
                    </DirectEvents>
                </ext:MenuItem>
            </Items>
        </ext:Menu>
        </form>
    </body>
    </html>
    Thanx

    Matteo

  6. #6
    Ext.NET - Dev Team Vladimir's Avatar
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    15,357

    RE: [CLOSED] [1.0] MenuItem Click DirectEvent

    Hi,

    I see, you have "A potentially dangerous Request.Form value was detected from the client" exception.
    You can set ValidateRequest="false" for the Page or use Cls property for TreeNode to set red color
    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  7. #7
    Ext.NET - Dev Team Vladimir's Avatar
    Join Date
    Mar 2008
    Location
    Russia
    Posts
    15,357

    RE: [CLOSED] [1.0] MenuItem Click DirectEvent

    Hi,

    Or you can disable selection submit (see SelectionSubmitConfig property of the TreePanel, DisableAutomaticSubmit)

    Vladimir Shcheglov
    Ext.NET, Inc.
    Development Team

    Ext.NET Examples | Ext.NET API Docs | ExtJS API Docs | Twitter | Jobs

  8. #8
    Member methode's Avatar
    Join Date
    Oct 2008
    Location
    ITALY
    Posts
    427

    RE: [CLOSED] [1.0] MenuItem Click DirectEvent

    Perfect, thanx Vald.

    I'll post my code here:

    Code:
    CSS
    
    .nodeDisabled .x-tree-node-anchor span{ color:Red !important; }
    
    C#
    
    ...
    asyncNode.Cls = "nodeDisabled";
    Matteo

Similar Threads

  1. Replies: 5
    Last Post: Mar 19, 2014, 3:35 AM
  2. How to find the URL on click of menuitem
    By krishna in forum 1.x Help
    Replies: 1
    Last Post: Mar 31, 2011, 6:27 AM
  3. How to find the URL on click of menuitem
    By krishna in forum 1.x Help
    Replies: 1
    Last Post: Mar 31, 2011, 5:29 AM
  4. How to get parent menuItem when click menuItem?
    By zhangsir199 in forum 1.x Help
    Replies: 2
    Last Post: Jan 21, 2011, 2:58 AM
  5. Replies: 2
    Last Post: Oct 22, 2010, 11:04 AM

Posting Permissions