This is a migrated thread and some comments may be shown as answers.

RadComboBox - Using EmptyMessage w/ Javascript

1 Answer 198 Views
UI for ASP.NET AJAX in ASP.NET MVC
This is a migrated thread and some comments may be shown as answers.
Larry
Top achievements
Rank 1
Larry asked on 06 Jul 2009, 07:08 PM
Hey,

I'm using a series of RadComboBoxes in a search screen.  I access the radcombobox text properties in a javascript function that calls radOpen.   The reason I use the text property instead of the "value" property is because the user my not actually select a dropdown value.   However when I set "EmptyMessage" to some value other than "" or blank it sets the text property. Is there a way to use EmptyMessage without it setting the text property of the radcombobox?
<%@ Page Title="Event Presentation Archive Search" Language="C#" MasterPageFile="~/assets/template/main.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
<%@ MasterType VirtualPath="~/assets/template/main.master" %> 
 
<asp:Content ID="Content1" ContentPlaceHolderID="_ContentBanner" Runat="Server">  
</asp:Content> 
<asp:Content ID="Content2" ContentPlaceHolderID="_ContentSideNav" Runat="Server">  
    <eserve:sidemenu runat="server" /> 
</asp:Content> 
<asp:Content ID="Content3" ContentPlaceHolderID="_ContentMain" Runat="Server">  
<h2>Welcome to Event Presentation Archive!</h2> 
<br /> 
 
   <script type="text/javascript">  
 
        function openRadWindow() {  
            var oWnd = radopen("SearchSessionResult.aspx?"  
                    + "sessionNumber=" + getText($find("<%= RadComboBoxSessionNumber.ClientID %>"))  
                    + "&sessionDate=" + getDate(document.getElementById("<%= eventDate.ClientID %>").value)  
                    + "&speaker=" + getText($find("<%= RadComboBoxSpeaker.ClientID %>"))  
                    + "&level=" + getText($find("<%= RadComboBoxLevel.ClientID %>"))  
                    + "&track=" + getText($find("<%= RadComboBoxTrack.ClientID %>"))  
                    + "&program=" + getText($find("<%= RadComboBoxProgram.ClientID %>"))  
                    + "&event=" + getText($find("<%= RadComboBoxEvent.ClientID %>"))  
                    + "&year=" + getText($find("<%= RadComboBoxYear.ClientID %>"))  
                    + "&title=" + getText($find("<%= RadComboBoxTitle.ClientID %>"))  
                    + "&room=" //+ Room  
                    + "&distributable=" // + Publishable  
                    , "AddBlock");  
            //oWnd.SetSize(1000, 400);  
            oWnd.Center();  
        }  
 
//        Moved To assets/template/main.master          
//        function openCartWindow() {  
//            var oWnd = radopen("ViewShoppingCart.aspx", "AddBlock");  
//            //oWnd.SetSize(700, 350);  
//            oWnd.Center();  
//        }  
 
        function getText(_combo) {  
            return _combo.get_text();  
        }  
 
        function getDate(_datestring) {  
            if (_datestring.length > 0) {  
                var _datearray = _datestring.split("-");  
                return _datearray[1] + "/" + _datearray[2] + "/" + _datearray[0];  
            }  
            else {  
                return "";  
            }  
        }  
          
        function clearForm() {  
            clearSearch($find("<%= RadComboBoxSessionNumber.ClientID %>"));  
            clearDateSearch($find("<%= eventDate.ClientID %>"));  
            clearSearch($find("<%= RadComboBoxSpeaker.ClientID %>"));  
            clearSearch($find("<%= RadComboBoxLevel.ClientID %>"));  
            clearSearch($find("<%= RadComboBoxTrack.ClientID %>"));  
            clearSearch($find("<%= RadComboBoxProgram.ClientID %>"));  
            clearSearch($find("<%= RadComboBoxTitle.ClientID %>"));  
            clearSearch($find("<%= RadComboBoxEvent.ClientID %>"));  
            clearSearch($find("<%= RadComboBoxYear.ClientID %>"));  
        }  
 
 
        function clearSearch(_box) {  
            _box.clearSelection();  
        }  
 
        function clearDateSearch(_datepicker) {  
            _datepicker.clear();  
        }  
 
//        Moved To assets/template/main.master  
//        function updatePage() {  
//            // Will Do a Postback when the popup windows are closed to update pending and items.  
//            document.forms[0].submit();  
//        }  
 
   </script>      
 
   <form runat="server" id="mainForm" method="post" style="width: 100%;float:left;">  
 
    <p>Enter your search criteria to find the session you are looking for.   The search boxes are Google-like and support type ahead text entry.</p> 
      <eserve:RadScriptManager ID="RadScriptManager1" runat="server" EnablePageMethods="true"/>  
      <eserve:RadAjaxPanel runat="server" ID="RadAjaxPanel1">  
         <div class="iform">  
             <div class="irow">  
                 <span class="ilabel"><asp:Label ID="Label1" runat="server" AssociatedControlID="RadComboBoxSessionNumber" >Session ID:</asp:Label></span>  
                 <eserve:RadComboBox  
                    ID="RadComboBoxSessionNumber" 
                    Skin="Gray" 
                    runat="server"   
                    Height="200px"   
                    Width="200px" 
                    DropDownWidth="298px" 
                    EmptyMessage=""   
                    HighlightTemplatedItems="true" 
                    Filter="Contains" 
                    EnableLoadOnDemand="true"   
                    OnItemsRequested="RadComboBox_ItemsRequested" 
                    DataTextField="sessionnumber" 
                    DataValueField="sessionnumber" 
                    MarkFirstMatch="false" 
                    EnableViewState="true" 
                    ShowToggleImage="false" 
                    ToolTip="Search On Session Number">  
                 </eserve:RadComboBox> 
             </div> 
             <div class="irow">  
                 <span class="ilabel"><asp:Label ID="Label9" runat="server" AssociatedControlID="RadComboBoxTitle" >Title:</asp:Label></span>  
                 <eserve:RadComboBox  
                        ID="RadComboBoxTitle" 
                        Skin="Gray" 
                        runat="server"   
                        Height="200px"   
                        Width="300px" 
                        DropDownWidth="498px" 
                        EmptyMessage=""   
                        HighlightTemplatedItems="true" 
                        Filter="Contains" 
                        EnableLoadOnDemand="true"   
                        OnItemsRequested="RadComboBox_ItemsRequested" 
                        DataTextField="title" 
                        DataValueField="title" 
                        MarkFirstMatch="false" 
                        EnableViewState="true" 
                        ShowToggleImage="false" 
                        ToolTip="Search On Title">  
                 </eserve:RadComboBox> 
             </div> 
               
<%--             <div class="irow">  
                 <span class="ilabel"><asp:Label ID="Label2" runat="server" AssociatedControlID="RadComboBoxDate" >Date:</asp:Label></span>  
                 <eserve:RadComboBox  
                        ID="RadComboBoxDate" 
                        Skin="Gray" 
                        runat="server"   
                        Width="100px" 
                        DropDownWidth="100px" 
                        EmptyMessage=""   
                        HighlightTemplatedItems="true" 
                        ShowToggleImage="true" 
                        ToolTip="Search On Date">  
                        <Items> 
                            <eserve:RadComboBoxItem Text="" />    
                            <eserve:RadComboBoxItem Text="05/04/2009" />    
                            <eserve:RadComboBoxItem Text="05/05/2009" />    
                            <eserve:RadComboBoxItem Text="05/06/2009" />    
                            <eserve:RadComboBoxItem Text="05/07/2009" />    
                        </Items>    
                 </eserve:RadComboBox> 
             </div>--%> 
 
             <div class="irow">  
                 <span class="ilabel"><asp:Label ID="Label10" runat="server" AssociatedControlID="eventDate" >Event Date:</asp:Label></span>  
                 <eserve:RadDatePicker ID="eventDate" runat="server" Skin="Office2007">  
                 </eserve:RadDatePicker> 
             </div> 
 
             <div class="irow">  
                 <span class="ilabel"><asp:Label ID="Label3" runat="server" AssociatedControlID="RadComboBoxSpeaker" >Speaker:</asp:Label></span>  
                 <eserve:RadComboBox  
                        ID="RadComboBoxSpeaker" 
                        Skin="Gray" 
                        runat="server"   
                        Height="200px"   
                        Width="200px" 
                        DropDownWidth="298px" 
                        EmptyMessage=""   
                        HighlightTemplatedItems="true" 
                        Filter="Contains" 
                        EnableLoadOnDemand="true"   
                        OnItemsRequested="RadComboBox_ItemsRequested" 
                        DataTextField="speakername" 
                        DataValueField="speakername" 
                        MarkFirstMatch="false" 
                        EnableViewState="true" 
                        ShowToggleImage="false" 
                        ToolTip="Search On Speaker">  
                 </eserve:RadComboBox> 
             </div> 
             <div class="irow">  
                 <span class="ilabel"><asp:Label ID="Label4" runat="server" AssociatedControlID="RadComboBoxLevel" >Level:</asp:Label></span>  
                 <eserve:RadComboBox  
                        ID="RadComboBoxLevel" 
                        Skin="Gray" 
                        runat="server"   
                        Height="200px"   
                        Width="200px" 
                        DropDownWidth="298px" 
                        EmptyMessage=""   
                        HighlightTemplatedItems="true" 
                        Filter="Contains" 
                        EnableLoadOnDemand="true"   
                        OnItemsRequested="RadComboBox_ItemsRequested" 
                        DataTextField="level" 
                        DataValueField="level" 
                        MarkFirstMatch="false" 
                        EnableViewState="true" 
                        ShowToggleImage="false" 
                        ToolTip="Search On Level">  
                 </eserve:RadComboBox> 
             </div> 
             <div class="irow">  
                 <span class="ilabel"><asp:Label ID="Label5" runat="server" AssociatedControlID="RadComboBoxTrack" >Track:</asp:Label></span>  
                 <eserve:RadComboBox  
                        ID="RadComboBoxTrack" 
                        Skin="Gray" 
                        runat="server"   
                        Height="200px"   
                        Width="200px" 
                        DropDownWidth="298px" 
                        EmptyMessage=""   
                        HighlightTemplatedItems="true" 
                        Filter="Contains" 
                        EnableLoadOnDemand="true"   
                        OnItemsRequested="RadComboBox_ItemsRequested" 
                        DataTextField="track" 
                        DataValueField="track" 
                        MarkFirstMatch="false" 
                        EnableViewState="true" 
                        ShowToggleImage="false" 
                        ToolTip="Search On Track">  
                 </eserve:RadComboBox> 
             </div> 
             <div class="irow">  
                 <span class="ilabel"><asp:Label ID="Label6" runat="server" AssociatedControlID="RadComboBoxProgram" >Program:</asp:Label></span>  
                 <eserve:RadComboBox  
                        ID="RadComboBoxProgram" 
                        Skin="Gray" 
                        runat="server"   
                        Height="200px"   
                        Width="200px" 
                        DropDownWidth="298px" 
                        EmptyMessage=""   
                        HighlightTemplatedItems="true" 
                        Filter="Contains" 
                        EnableLoadOnDemand="true"   
                        OnItemsRequested="RadComboBox_ItemsRequested" 
                        DataTextField="program" 
                        DataValueField="program" 
                        MarkFirstMatch="false" 
                        EnableViewState="true" 
                        ShowToggleImage="false" 
                        ToolTip="Search On Program">  
                 </eserve:RadComboBox> 
             </div> 
             <div class="irow">  
                 <span class="ilabel"><asp:Label ID="Label7" runat="server" AssociatedControlID="RadComboBoxEvent" >Event:</asp:Label></span>  
                 <eserve:RadComboBox  
                        ID="RadComboBoxEvent" 
                        Skin="Gray" 
                        runat="server"   
                        Height="200px"   
                        Width="200px" 
                        DropDownWidth="298px" 
                        EmptyMessage=""   
                        HighlightTemplatedItems="true" 
                        Filter="Contains" 
                        EnableLoadOnDemand="true"   
                        OnItemsRequested="RadComboBox_ItemsRequested" 
                        DataTextField="event" 
                        DataValueField="event" 
                        MarkFirstMatch="false" 
                        EnableViewState="true" 
                        ShowToggleImage="false" 
                        ToolTip="Search On Event">  
                 </eserve:RadComboBox> 
             </div> 
             <div class="irow">  
                 <span class="ilabel"><asp:Label ID="Label8" runat="server" AssociatedControlID="RadComboBoxYear" >Year:</asp:Label></span>  
                 <eserve:RadComboBox  
                        ID="RadComboBoxYear" 
                        Skin="Gray" 
                        runat="server"   
                        Height="200px"   
                        Width="70px" 
                        DropDownWidth="70px" 
                        EmptyMessage=""   
                        HighlightTemplatedItems="true" 
                        ShowToggleImage="true" 
                        ToolTip="Search On Year">  
                        <Items> 
                            <eserve:RadComboBoxItem Text="" />    
                            <eserve:RadComboBoxItem Text="2009" /> 
                        </Items>    
                 </eserve:RadComboBox> 
             </div> 
 
<%--             <div class="irow">  
                 <span class="ilabel"><asp:Label ID="Label10" runat="server" AssociatedControlID="RadComboBoxRoom" >Room:</asp:Label></span>  
                 <eserve:RadComboBox  
                        ID="RadComboBoxRoom" 
                        Skin="Gray" 
                        runat="server"   
                        Height="200px"   
                        Width="200px" 
                        DropDownWidth="298px" 
                        EmptyMessage=""   
                        HighlightTemplatedItems="true" 
                        Filter="Contains" 
                        EnableLoadOnDemand="true"   
                        OnItemsRequested="RadComboBox_ItemsRequested" 
                        DataTextField="room" 
                        DataValueField="room" 
                        MarkFirstMatch="false" 
                        EnableViewState="true" 
                        ShowToggleImage="false" 
                        ToolTip="Search On Room">  
                 </eserve:RadComboBox> 
             </div>--%> 
<%--             <div class="irow">  
                 <span class="ilabel"><asp:Label ID="Label7" runat="server" AssociatedControlID="RadComboBoxDate" >Publishable:</asp:Label></span>  
                 <eserve:RadComboBox  
                        ID="RadComboBoxPublishable" 
                        Skin="Gray" 
                        runat="server"   
                        Width="70px" 
                        DropDownWidth="70px" 
                        EmptyMessage=""   
                        HighlightTemplatedItems="true" 
                        ShowToggleImage="true" 
                        ToolTip="Search On Publishable">  
                        <Items> 
                            <eserve:RadComboBoxItem Text="" />    
                            <eserve:RadComboBoxItem Text="Yes" Value="Y" />    
                            <eserve:RadComboBoxItem Text="No" Value="N" />    
                            <eserve:RadComboBoxItem Text="Partial" Value="P" />    
                        </Items>    
                 </eserve:RadComboBox> 
             </div>--%> 
             <div class="irow">  
                 <span class="ilabel"><asp:Label ID="Label11" runat="server" AssociatedControlID="Button1" >&nbsp;</asp:Label></span>  
                 <%--<asp:Button ID="Button1" runat="server" OnClientClick="openRadWindow(); return false;" Text="search" Width="100" CssClass="button" />--%> 
                 <asp:LinkButton ID="Button1" runat="server" OnClientClick="openRadWindow(); return false;" Text="search" Width="100" CssClass="button" /> 
                 <asp:LinkButton ID="btnClear" runat="server" Text="clear" OnClientClick="clearForm(); return false;" Width="100" CssClass="button" /> 
                 <%--<asp:LinkButton ID="btnViewCart" runat="server" Text="view cart" OnClientClick="openCartWindow(); return false;" Width="100" CssClass="button" />--%> 
             </div> 
         </div> 
         <eserve:RadWindowManager   
            ShowContentDuringLoad="false" 
            KeepInScreenBounds="true" 
            DestroyOnClose="true" 
            Skin="Gray"   
              
            ID="RadWindowManager1" 
            Width="700px"   
             
            VisibleStatusbar="false" 
                           
            runat="server" 
            OnClientClose="updatePage">  
         </eserve:RadWindowManager> 
       </eserve:RadAjaxPanel> 
   </form>         
                       
                       
                       
                       
                       
</asp:Content> 
<asp:Content ID="Content4" ContentPlaceHolderID="_ContentSideBar" Runat="Server">  
</asp:Content> 
 
 

1 Answer, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 07 Jul 2009, 10:37 AM
Hi Larry,

No, the Empty Message is always set as the text of the ComboBox. 

However, you can differentiate between the Empty Message text and that entered by the user by using the get_emptyMessage() property at the client and compare it to the value of the get_text() property.

If these values are different, then you can use the text (as being entered by the user or by the selection of an Item).

Kind regards,
Simon
the Telerik team

Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
Tags
UI for ASP.NET AJAX in ASP.NET MVC
Asked by
Larry
Top achievements
Rank 1
Answers by
Simon
Telerik team
Share this question
or