我正在使用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;
}
}
这里而不是状态栏中的显示错误消息我想在组合框中显示错误信息 ..所以我怎么办?
答案 0 :(得分: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>