[CLOSED] [1.0] Get values of Component rendered by XRender

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] [1.0] Get values of Component rendered by XRender

    Hi
    I create some componentes (TextFields, and ComboBoxes) in a DirectEvent. Then I want to get the values edited by the user of theese components. How do i do that. (I do not recreate the components in the second directevent, is that needed). I manage to get the values of the TextField by this code

    Works
    string text = X.GetCmp<TextField>("TextField1").Text;
    Does not work
    string text = X.GetCmp<ComboBox>("ComboBox1").SelectedItem.Value;
    But this code does not word for the combobox. Any Idea?

    Thanks
    Mikae
    Last edited by geoffrey.mcgill; Sep 13, 2010 at 8:52 PM. Reason: [CLOSED]
  2. #2
    Hello!

    It needs to recreate a control during each request (for example, in the Page_Load) if you want to handle it on server side.
    Both controls are created during DirectEvent or TextField1 is defined in a markup?
    Could you provide us with a sample code? We should look how all is configured.
  3. #3
    Hi

    Like this simple example, how do I get the value of the combobox?

    <%@ Page Language="C#" ValidateRequest="false"%>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }
        public void CreateCombo(object sender, DirectEventArgs e)
        { 
        
            var obj = new Ext.Net.ComboBox{ ID = "combo1", FieldLabel = "Combo 1"};
            obj.Items.Add(new Ext.Net.ListItem("value1", "Value 1"));
            obj.Items.Add(new Ext.Net.ListItem("value2", "Value 2"));
            pnlFields.Items.Add(obj);
            obj.Render();
        }
        public void GetComboValue(object sender, DirectEventArgs e)
        {
            var combo = X.GetCmp<ComboBox>("combo1");
            X.MessageBox.Alert("Value", combo.SelectedItem.Value).Show();
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>Ext.NET Example</title>
      
    </head>
    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        
        <ext:Panel ID="pnlFields" AutoScroll="true" BodyBorder="false" AutoHeight="true" runat="server" Layout="Form">                    
        </ext:Panel>   
        
        <ext:Button runat="server" Text="Create combo"><DirectEvents><Click OnEvent="CreateCombo"></Click></DirectEvents></ext:Button>
        <ext:Button runat="server" Text="Get combo value"><DirectEvents><Click OnEvent="GetComboValue"></Click></DirectEvents></ext:Button>
        </form>
    </body>
    </html>
    Thanks!
    Mikael
  4. #4
    Hello!

    If it needs to handle a control during any DirectEvent the contol must be recreated during each request (in the Page_Load or Page_Init, for example).

    I would suggest you to use DirectMethod instead of DirectEvent or pass a combo's value to server using the ExtraParams section.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        public void CreateCombo(object sender, DirectEventArgs e)
        {
            var obj = new Ext.Net.ComboBox { ID = "combo1", FieldLabel = "Combo 1" };
            obj.Items.Add(new Ext.Net.ListItem("value1", "Value 1"));
            obj.Items.Add(new Ext.Net.ListItem("value2", "Value 2"));
            pnlFields.Items.Add(obj);
            obj.Render();
        }
    
        public void GetComboValue1(object sender, DirectEventArgs e)
        {
            X.MessageBox.Alert("Value", e.ExtraParams["value"]).Show();
        }
    
        [DirectMethod]
        public void GetComboValue2(String value)
        {
            X.MessageBox.Alert("Value", value).Show();
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:Panel ID="pnlFields" runat="server" />
        <ext:Button runat="server" Text="Create combo">
            <DirectEvents>
                <Click OnEvent="CreateCombo" />
            </DirectEvents>
        </ext:Button>
        <ext:Button runat="server" Text="Get combo value by DirectEvent">
            <DirectEvents>
                <Click OnEvent="GetComboValue1">
                    <ExtraParams>
                        <ext:Parameter Name="value" Value="Ext.get('combo1').getValue()" Mode="Raw"/>
                    </ExtraParams>
                </Click>
            </DirectEvents>
        </ext:Button>
        <ext:Button runat="server" Text="Get combo value by DirectMethod">
            <Listeners>
                <Click Handler="Ext.net.DirectMethods.GetComboValue2(Ext.get('combo1').getValue())" />
            </Listeners>
        </ext:Button>
        </form>
    </body>
    </html>
    Also please note that when a control is added to the Items collection it is also added in the Controls collection automatically.

    Example
    pnlFields.Items.Add(obj);
    pnlFields.Controls.Add(obj); // it's unnecessary
  5. #5
    ok great, thanks!
  6. #6
    Hi,

    Another option, read combo value directly from Request.Form
    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        public void CreateCombo(object sender, DirectEventArgs e)
        {
            var obj = new Ext.Net.ComboBox { ID = "combo1", FieldLabel = "Combo 1" };
            obj.Items.Add(new Ext.Net.ListItem("value1", "Value 1"));
            obj.Items.Add(new Ext.Net.ListItem("value2", "Value 2"));
            pnlFields.Items.Add(obj);
            obj.Render();
        }
     
        public void GetComboValue1(object sender, DirectEventArgs e)
        {        
            X.MessageBox.Alert("Value", Request.Form["combo1"]).Show();
        }
    </script>
     
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:Panel ID="pnlFields" runat="server" />
        <ext:Button runat="server" Text="Create combo">
            <DirectEvents>
                <Click OnEvent="CreateCombo" />
            </DirectEvents>
        </ext:Button>
        <ext:Button runat="server" Text="Get combo value">
            <DirectEvents>
                <Click OnEvent="GetComboValue1">                
                </Click>
            </DirectEvents>
        </ext:Button>    
        </form>
    </body>
    </html>
  7. #7
    How do I get the value of the combo? I only manage to get the text, but I need the actual value of the combo?

    Thanks!
  8. #8
    Hi,

    Please add "_Value"
    Request.Form["combo1_Value"]
  9. #9
    GREAT!
    How do I get the value in java script?

    This gets the text, need the value here
     
    Ext.get('combo1').getValue()??
  10. #10
    Hi,

    Need use getCmp
    Ext.getCmp('combo1').getValue()
    or
    combo1.getValue()
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 1
    Last Post: Mar 10, 2012, 1:45 PM
  2. What is the use XRender? Where it can be useful?
    By vjsrinath in forum 1.x Help
    Replies: 4
    Last Post: Feb 14, 2012, 12:06 PM
  3. [CLOSED] DirectMethod/XRender Issue
    By logicspeak in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 26, 2011, 5:43 AM
  4. [CLOSED] XRender Icon ComboBox
    By IanPearce in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 09, 2010, 11:23 AM
  5. Replies: 1
    Last Post: May 22, 2009, 7:38 AM

Posting Permissions