1

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;
            }              
        }

ここでは、ステータスバーにエラーメッセージを表示する代わりに、コンボボックスにエラーメッセージを表示したい..どうすればいいですか??

4

1 に答える 1

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>
于 2012-09-04T04:38:01.130 に答える