Value && Text in SelectBox in CodeBehind

  1. #1

    Value && Text in SelectBox in CodeBehind

    Hey.

    I want to show in the selectbox "hello" but you save the identifier "1"

    As I can do?

    thank you very much

    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
     
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            this.xample.Value = 1;
            this.xample.Text = "Hello";
        }
    
        protected void test(object sender, DirectEventArgs e)
        {
            //I want that is worth "1" but it "hello"
            string test = e.ExtraParams["test"];
            this.exit.Text = test;
        }
    </script>
     
    <!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 id="Head1" runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server"  />
    
            <ext:Button runat="server" Text="Cambiar" Icon="Accept" >
                <DirectEvents>
                    <Click OnEvent="test" >
                        <ExtraParams>
                            <ext:Parameter Name="test" Value="xample.getValue()" Mode="Raw" />
                        </ExtraParams>
                    </Click>
                </DirectEvents>
            </ext:Button>
    
            <ext:SelectBox ID="xample" runat="server" />   
            
            <ext:TextField ID="exit" runat="server" HideLabel="true" />   
    </body>
    </html>
  2. #2
    Hi,

    In your case Text just overrides Value.

    It should look this way:

    Example
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!X.IsAjaxRequest)
        {
            this.SelectBox1.Items.Add(new Ext.Net.ListItem("Hello", "1"));
            this.SelectBox1.SelectedItem.Value = "1";
        }
    }
  3. #3
    Thank you very much.

    It works perfectly!

Similar Threads

  1. Replies: 1
    Last Post: Jun 28, 2012, 9:06 PM
  2. How can i find items in selectbox by value or text
    By abhi_sheklohiya in forum 1.x Help
    Replies: 0
    Last Post: Mar 27, 2012, 1:46 PM
  3. Replies: 4
    Last Post: Oct 24, 2011, 3:34 AM
  4. Replies: 5
    Last Post: Sep 21, 2010, 5:08 PM
  5. [CLOSED] HTMLEditor - dropped text does not show up in codebehind
    By SFritsche in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Sep 13, 2010, 9:39 PM

Posting Permissions