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

[Solved] Combobox in Custom Control

1 Answer 162 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 09 Mar 2010, 04:40 PM
Hi,

I'm trying to use some combo boxes in a custom control.  To get this working I am using AJAX and have a function that I call in the custom control backend that ties the AJAXified controls to the main page's AjaxManager.  This works for the radnumerictextbox controls on the page but for the radcombobox controls the selected index changed event doesn't fire.  If I take the controls out of the custom control and run them in a standard web page it works fine.  Any ideas?  Code is below:

Custom control webpage:
    <tr> 
        <td class="label">Start Date Modifier:</td> 
        <td class="halfWidth">  
            <telerik:RadNumericTextBox ID="uxStartDateModInterval" runat="server" Width="30" DataType="System.Int16" MaxValue="100" MinValue="-100" AutoPostBack="True" ><NumberFormat DecimalDigits="0" /></telerik:RadNumericTextBox> 
            &nbsp;  
            <telerik:RadComboBox ID="uxStartDateModIntervalTypeID" Runat="server" Width="90" MarkFirstMatch="True" AutoPostBack="True" OnSelectedIndexChanged="uxStartDateModIntervalTypeID_SelectedIndexChanged">  
                <Items> 
                    <telerik:RadComboBoxItem runat="server" Text="Day(s)" Value="1" /> 
                    <telerik:RadComboBoxItem runat="server" Text="Week(s)" Value="2" /> 
                    <telerik:RadComboBoxItem runat="server" Text="Month(s)" Value="3" /> 
                    <telerik:RadComboBoxItem runat="server" Text="Quarter(s)" Value="4" /> 
                    <telerik:RadComboBoxItem runat="server" Text="Year(s)" Value="5" /> 
                </Items> 
            </telerik:RadComboBox> 
        </td> 
        <td class="labelBlackLeft" colspan="2">  
            <asp:label ID="uxStartDateExample" runat="server" Text="Ensure both fields have data."></asp:label> 
        </td> 
    </tr> 
    <tr> 
        <td class="label">End Date Modifier:</td> 
        <td class="halfWidth">  
            <telerik:RadNumericTextBox ID="uxEndDateModInterval" runat="server" Width="30" DataType="System.Int16" MaxValue="100" MinValue="-100" AutoPostBack="True" ><NumberFormat DecimalDigits="0" /></telerik:RadNumericTextBox> 
            &nbsp;  
            <telerik:RadComboBox ID="uxEndDateModIntervalTypeID" Runat="server" Width="90" MarkFirstMatch="True" AutoPostBack="True" OnSelectedIndexChanged="uxEndDateModIntervalTypeID_SelectedIndexChanged">  
                <Items> 
                    <telerik:RadComboBoxItem runat="server" Text="Day(s)" Value="1" /> 
                    <telerik:RadComboBoxItem runat="server" Text="Week(s)" Value="2" /> 
                    <telerik:RadComboBoxItem runat="server" Text="Month(s)" Value="3" /> 
                    <telerik:RadComboBoxItem runat="server" Text="Quarter(s)" Value="4" /> 
                    <telerik:RadComboBoxItem runat="server" Text="Year(s)" Value="5" /> 
                </Items> 
            </telerik:RadComboBox> 
        </td> 
        <td class="labelBlackLeft" colspan="2">  
            <asp:label ID="uxEndDateExample" runat="server" Text="Ensure both fields have data."></asp:label> 
        </td> 
    </tr> 

Custom control codebehind
        Public Sub SetupAJAX(ByRef radAjaxManager As Telerik.Web.UI.RadAjaxManager)  
            radAjaxManager.AjaxSettings.AddAjaxSetting(Me.uxStartDateModInterval, Me.uxStartDateExample)  
            radAjaxManager.AjaxSettings.AddAjaxSetting(Me.uxStartDateModIntervalTypeID, Me.uxStartDateExample)  
            radAjaxManager.AjaxSettings.AddAjaxSetting(Me.uxEndDateModInterval, Me.uxEndDateExample)  
            radAjaxManager.AjaxSettings.AddAjaxSetting(Me.uxEndDateModIntervalTypeID, Me.uxEndDateExample)  
        End Sub 
 
        Protected Sub uxStartDateModIntervalTypeID_SelectedIndexChanged(ByVal o As ObjectByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles uxStartDateModIntervalTypeID.SelectedIndexChanged  
            ModifyDate(uxStartDateModInterval, uxStartDateModIntervalTypeID, uxStartDateExample, False)  
        End Sub 
 
        Protected Sub uxEndDateModIntervalTypeID_SelectedIndexChanged(ByVal o As ObjectByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles uxEndDateModIntervalTypeID.SelectedIndexChanged  
            ModifyDate(uxEndDateModInterval, uxEndDateModIntervalTypeID, uxEndDateExample, False)  
        End Sub 
 
        Protected Sub uxStartDateModInterval_TextChanged(ByVal sender As ObjectByVal e As EventArgs) Handles uxStartDateModInterval.TextChanged  
            ModifyDate(uxStartDateModInterval, uxStartDateModIntervalTypeID, uxStartDateExample, False)  
        End Sub 
 
        Protected Sub uxEndDateModInterval_TextChanged(ByVal sender As ObjectByVal e As EventArgs) Handles uxEndDateModInterval.TextChanged  
            ModifyDate(uxEndDateModInterval, uxEndDateModIntervalTypeID, uxEndDateExample, False)  
        End Sub 

Finally on the page that has the custom control placed on it I use the following in the Page_Load event...

uxDateModifierControl.SetupAJAX(uxRadAjaxManager) 

Where uxDataModifierControl is the custom control ID....

Any thoughts?

Regards,

Jon



1 Answer, 1 is accepted

Sort by
0
Jon
Top achievements
Rank 1
answered on 09 Mar 2010, 05:33 PM
Whoops - looks like this was down to an issue with form validation.

The RadNumericTextbox has causes validation set to false by default whereas it appears that the RadComboBox has CausesValidation set to true.  As such my form was throwing up an issue and the change event wasn't processed (no post back appeared)...
Tags
ComboBox
Asked by
Jon
Top achievements
Rank 1
Answers by
Jon
Top achievements
Rank 1
Share this question
or