RadComboBox EmptyMessage not showing on initial load
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...".
Since this RadComboBox
is not loading on demand, in order for the EmptyTextMessage
to work as you expect, You need to also set the property AllowCustomText
to True
From Telerik:
The EmptyMessage property can be used when the AllowCustomText property is set to True (it is always true in a Load-on-Demand scenario). It sets a text in the input field of the combobox. This text disappears when the combobox gets the focus and appears again on blur if no item is selected.
精彩评论