Как динамически отображать сообщение об ошибке в поле со списком в ext.net

Я работаю с Ext.Net1.0. и я работаю с полем со списком.. когда я выбираю значение из поля со списком с помощью некоторого расчета, если значение уже используется, то я хочу динамически отображать сообщение об ошибке, тогда как я могу отобразить сообщение..??

<ext:ComboBox ID="cmbClient" runat="server" Width="200"
                                FieldLabel="Client Name"
                                DisplayField="client_firstName" ValueField="clientId"
                                AllowBlank="false" BlankText="Select Client"
                                MsgTarget="Title" EmptyText="Select Client">
                                <Store>
                                     <ext:Store runat="server" ID="clientStore">           
                                        <Reader>
                                            <ext:JsonReader IDProperty="clientId">
                                                <Fields>
                                                    <ext:RecordField Name="clientId" />
                                                    <ext:RecordField Name="client_firstName"/>
                                                </Fields>
                                            </ext:JsonReader>
                                        </Reader>         
                                        <SortInfo Field="client_firstName" Direction="ASC" />
                                    </ext:Store>
                                </Store>
                                 <DirectEvents>
                                        <Select OnEvent="cmbClient_Change"></Select>
                                 </DirectEvents>
                            </ext:ComboBox>

код страницы cs

protected void cmbClient_Change(object sender, DirectEventArgs e)
        {

            int c = objapp.Count_SelectClient();
            if (c != 0)
            {
                statusbar.Show();
                this.statusbar.Text = cmbClient.SelectedItem.Text + " already having appoinment at selected time.";
                this.statusbar.Icon = Icon.Exclamation;
            }              
        }

здесь вместо отображения сообщения об ошибке в строке состояния я хочу отобразить сообщение об ошибке в поле со списком.. так как я могу ??


person Smily    schedule 03.09.2012    source источник


Ответы (1)


Попробуйте использовать этот пример:

<%@ Page Language="C#" %>

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Store1.DataSource = new object[]
        {
            new object[] { "AL", "Alabama", "The Heart of Dixie" },
            new object[] { "AK", "Alaska", "The Land of the Midnight Sun" },
            new object[] { "AZ", "Arizona", "The Grand Canyon State" },
            new object[] { "AR", "Arkansas", "The Natural State" },
            new object[] { "CA", "California", "The Golden State" },
            new object[] { "CO", "Colorado", "The Mountain State" },
            new object[] { "CT", "Connecticut", "The Constitution State" },
            new object[] { "DE", "Delaware", "The First State" },
            new object[] { "DC", "District of Columbia", "The Nation's Capital" },
            new object[] { "FL", "Florida", "The Sunshine State" },
            new object[] { "GA", "Georgia", "The Peach State" },
            new object[] { "HI", "Hawaii", "The Aloha State" },
            new object[] { "ID", "Idaho", "Famous Potatoes" }
        };

        this.Store1.DataBind();

    }
</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>Comboboxes - Ext.NET Examples</title>
    <script runat="server">

    protected void ComboxValueChanged(object sender, DirectEventArgs e)
    {
        var comboBox = (ComboBox)sender;
        if ((string)comboBox.Value != "ID")
        {    
            ResourceManager1.RegisterClientScriptBlock("showTooltip", string.Format("showTooltip('{0}');", comboBox.ClientID));
        }
    }

    </script>

    <script type="text/javascript">
        function showTooltip(elemId) {
            var cmp = Ext.getCmp(elemId);
            var t = new Ext.ToolTip({
                html: "It works...",
                closable: true,
                title: "Error value:",
                autoHide: false
            });

            var box = cmp.getBox();

            t.showAt([box.x + box.width, box.y]);
        }
    </script>
</head>
<body>
    <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />

        <ext:Store ID="Store1" runat="server">
            <Reader>
                <ext:ArrayReader>
                    <Fields>
                        <ext:RecordField Name="abbr" />
                        <ext:RecordField Name="state" />
                        <ext:RecordField Name="nick" />
                    </Fields>
                </ext:ArrayReader>
            </Reader>            
        </ext:Store>

        <ext:Button ID="Button1" runat="server" Text="Set 'IDAHO' value">
            <Listeners>
                <Click Handler="#{ComboBox1}.setValue('ID');" />
            </Listeners>
        </ext:Button>

        <h2>Not Editable:</h2>

        <ext:ComboBox 
            ID="ComboBox1" 
            runat="server" 
            StoreID="Store1" 
            Editable="false"
            DisplayField="state"
            ValueField="abbr"
            TypeAhead="true" 
            Mode="Local"
            ForceSelection="true"
            EmptyText="Select a state..."
            Resizable="true"
            SelectOnFocus="true"
            >
            <DirectEvents>
                <Change OnEvent="ComboxValueChanged"></Change>
            </DirectEvents>
        </ext:ComboBox>
    </form>
</body>
</html>
person Baidaly    schedule 04.09.2012