button click event not firing when combobox text changed

2 posts, 0 answers
  1. Igor
    Igor avatar
    1 posts
    Member since:
    Jul 2008

    Posted 06 Nov 2008 Link to this post

    I have a pageview in multipage. In pageview RadComboBox is defined and button is defined.
    Combobox asllows custom text and selectedindexchanged event is impelemtned on server.
    button click event is implemented on server.

    when text changed in combobox and button clicked, only selectedindexchanged is fired, button click event is not fired.

    I wonder how can I get both events fired.

    I have a small project included:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="testproj._Default" %> 
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
    <!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 runat="server">  
        <title>Untitled Page</title> 
        <form id="form1" runat="server">  
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
                    <telerik:AjaxSetting AjaxControlID="RadMultiPage1">  
                            <telerik:AjaxUpdatedControl ControlID="RadMultiPage1" /> 
            <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0">  
                <telerik:RadPageView ID="RadPageView1" runat="server">  
                    <telerik:RadComboBox ID="RadComboBox1" Runat="server" AllowCustomText="True"   
                        AutoPostBack="True" ChangeTextOnKeyBoardNavigation="False"   
                            <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1"   
                                Value="RadComboBoxItem1" /> 
                            <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem2"   
                                Value="RadComboBoxItem2" /> 
                        <CollapseAnimation Duration="200" Type="OutQuint" /> 
                    </telerik:RadComboBox><br /> 
                    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /> 
                    <br /> 
                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> 
                    <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label> 
                <telerik:RadPageView ID="RadPageView2" runat="server">  
                <telerik:RadPageView ID="RadPageView3" runat="server">  
    using System;  
    using System.Collections;  
    using System.Configuration;  
    using System.Data;  
    using System.Linq;  
    using System.Web;  
    using System.Web.Security;  
    using System.Web.UI;  
    using System.Web.UI.HtmlControls;  
    using System.Web.UI.WebControls;  
    using System.Web.UI.WebControls.WebParts;  
    using System.Xml.Linq;  
    namespace testproj  
        public partial class _Default : System.Web.UI.Page  
            protected void Page_Load(object sender, EventArgs e)  
            protected void RadComboBox1_SelectedIndexChanged(object o, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)  
                Label1.Text = "selected index changed";  
            protected void Button1_Click(object sender, EventArgs e)  
                Label2.Text = "button clicked";  
  2. Kevin Babcock
    Kevin Babcock avatar
    189 posts
    Member since:
    Mar 2007

    Posted 07 Nov 2008 Link to this post

    Hello Igor,

    I suspect your Button's OnClick event is not getting fired because you have set the RadComboBox's AutoPostBack property to true. What happens is when you change the RadComboBox selection, it send a post back to the server, which only fires the RadComboBox's SelectedIndexChanged event. When you click the Button, it sends a separate postback to the server, which fires the Buttons OnClick event. You won't see both events fired during the same post back because each control causes a post back separately. If you want to require the Button control be clicked to post the RadComboBox change back to the server, set the AutoPostBack property to false. Then when you click the Button, both the OnSelectedIndexChanged and the OnClick events will fire during the same post back.

    I hope that helps. If you have any additional questions, please let me know.

    Kevin Babcock
Back to Top