RadComboBox EmptyMessage 在初始加载时未显示
由于某种原因,我的 RadComboBox“EmptyMessage”没有在页面的初始加载中显示,但在我聚焦并模糊控制后它会显示。如何强制默认显示“EmptyMessage”?
我的 .aspx 如下:
<telerik:RadComboBox
ID="SomeFilter" runat="server"
EmptyMessage="Choose..."
OnClientSelectedIndexChanging="OnClientSelectedIndexChanging"
OnClientDropDownOpening="OnClientDropDownOpening"
OnClientDropDownClosing="OnClientDropDownClosing"
OnClientBlur="OnClientBlur">
<ItemTemplate>
<asp:CheckBox ID="ItemSelector" runat="server" />
<asp:Label runat="server" ID="ItemLabel" AssociatedControlID="ItemSelector">
<%# DataBinder.Eval(Container, "Text") %>
</asp:Label>
</ItemTemplate>
</telerik:RadComboBox>
我的代码隐藏:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SetSomeFilterDropDown();
}
}
private void SetSomeFilterDropDown()
{
SomeFilter.Items.Add(new RadComboBoxItem("Test1", "Test1"));
SomeFilter.Items.Add(new RadComboBoxItem("Test2", "Test2"));
SomeFilter.Items.Add(new RadComboBoxItem("Test3", "Test3"));
SomeFilter.DataBind();
}
我的 .aspx 中还有以下 javascript 方法:
var supressDropDownClosing = false;
OnClientDropDownClosing = function (sender, eventArgs) {
eventArgs.set_cancel(supressDropDownClosing);
sender.clearSelection();
}
OnClientSelectedIndexChanging = function (sender, eventArgs) {
eventArgs.set_cancel(supressDropDownClosing);
}
OnClientDropDownOpening = function (sender, eventArgs) {
supressDropDownClosing = true;
}
OnClientBlur = function (sender) {
supressDropDownClosing = false;
sender.toggleDropDown();
}
我的组合框默认为“Test1”,而不是“选择...”。然而,一旦我打开并关闭组合框,默认值就会更改为“选择...”。
For some reason my RadComboBox "EmptyMessage" is not showing on the initial load of the page but it does after I focus and blur out of the control. How can I force my "EmptyMessage" to show by default?
My .aspx is as follows:
<telerik:RadComboBox
ID="SomeFilter" runat="server"
EmptyMessage="Choose..."
OnClientSelectedIndexChanging="OnClientSelectedIndexChanging"
OnClientDropDownOpening="OnClientDropDownOpening"
OnClientDropDownClosing="OnClientDropDownClosing"
OnClientBlur="OnClientBlur">
<ItemTemplate>
<asp:CheckBox ID="ItemSelector" runat="server" />
<asp:Label runat="server" ID="ItemLabel" AssociatedControlID="ItemSelector">
<%# DataBinder.Eval(Container, "Text") %>
</asp:Label>
</ItemTemplate>
</telerik:RadComboBox>
My code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
SetSomeFilterDropDown();
}
}
private void SetSomeFilterDropDown()
{
SomeFilter.Items.Add(new RadComboBoxItem("Test1", "Test1"));
SomeFilter.Items.Add(new RadComboBoxItem("Test2", "Test2"));
SomeFilter.Items.Add(new RadComboBoxItem("Test3", "Test3"));
SomeFilter.DataBind();
}
I also have the following javascript methods in my .aspx:
var supressDropDownClosing = false;
OnClientDropDownClosing = function (sender, eventArgs) {
eventArgs.set_cancel(supressDropDownClosing);
sender.clearSelection();
}
OnClientSelectedIndexChanging = function (sender, eventArgs) {
eventArgs.set_cancel(supressDropDownClosing);
}
OnClientDropDownOpening = function (sender, eventArgs) {
supressDropDownClosing = true;
}
OnClientBlur = function (sender) {
supressDropDownClosing = false;
sender.toggleDropDown();
}
My combobox defaults to "Test1" by default instead of "Choose...". Once I open and close the combobox, however, the default changes to "Choose...".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于此
RadComboBox
不是按需加载,为了使EmptyTextMessage
按您的预期工作,您还需要将属性AllowCustomText
设置为True
来自 Telerik:
Since this
RadComboBox
is not loading on demand, in order for theEmptyTextMessage
to work as you expect, You need to also set the propertyAllowCustomText
toTrue
From Telerik: