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

button click event not firing when combobox text changed

1 Answer 233 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Igor asked on 06 Nov 2008, 11:43 PM
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" ""> 
<html xmlns="" > 
<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";  

1 Answer, 1 is accepted

Sort by
Kevin Babcock
Top achievements
Rank 1
answered on 08 Nov 2008, 03:16 AM
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
Asked by
Top achievements
Rank 1
Answers by
Kevin Babcock
Top achievements
Rank 1
Share this question