组合框onselectedindex更改了按钮控件的事件触发 [英] Combobox onselectedindexchanged event firing from button control

查看:87
本文介绍了组合框onselectedindex更改了按钮控件的事件触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个Web表单,其中有两个组合框控件和一个按钮.
Page_Load事件中填充Firstcombobox数据.

firstcombobox.OnsSelectedIndexChanged事件中,我想根据用户选择在第二个组合框数据中填充数据.

但是firstcombobox.OnSelectedIndexChanged事件不会在项目选择上触发,而是在单击按钮时触发.

这是一段代码

Hi,

I have a web form in which two combo box controls and one button.
Firstcombobox data is populated in Page_Load event.

In the firstcombobox.OnsSelectedIndexChanged event i want to populate data in second combo box data based on user selection.

But the firstcombobox.OnSelectedIndexChanged event is not firing on item selection instead it is firing when button is clicked.

Here is the piece of code

  <table>
     <tr>
        <td align="left" >
            <asp:Label ID="labeldate" Text="Starting Date   " runat="server" ></asp:Label>
        </td>
        <td align="left" colspan="2" >
            <asp:TextBox ID="start_date" runat="server"></asp:TextBox>
        </td>
        <ajaxToolkit:CalendarExtender ID="Cal1"  runat="server" TargetControlID="start_date" />
        </tr>

        <br />
        <br />
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="start_date" Text="Starting date is required!" runat="server"></asp:RequiredFieldValidator>

       <tr> <td align="left"><asp:Label ID="label9" Text="Project Code" runat="server" ></asp:Label></td>
       <td colspan="5" ><ajaxToolkit:ComboBox ID="project_code"  runat="server" AutoPostBack="false" Width="312px"   önSelectedIndexChanged="Get_timesheets" > </ajaxToolkit:ComboBox></td>
       </tr>

       <tr> <asp:UpdatePanel ID="updatePanel1"  runat="server" UpdateMode="Conditional">
       <ContentTemplate>
       <td align="left"><asp:Label ID="label10" Text="Timesheet(s) Present" runat="server" ></asp:Label></td>
       <td colspan="5" ><ajaxToolkit:ComboBox ID="Combo_time"  runat="server"   önSelectedIndexChanged="Get_data"  Width="312px"> </ajaxToolkit:ComboBox></td>
       </ContentTemplate>
       </asp:UpdatePanel>

        <td align="center">
            <asp:Button ID="submit" runat="server" Text="OK" Width="60px" OnClick="show_timesheet" />
        </td>
       </tr>
       <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ValidationGroup="btnprj" InitialValue="--Select Project--" ErrorMessage="Please select project code"
       ControlToValidate="project_code" Text="Project code is required!" runat="server"></asp:RequiredFieldValidator>
</table>



不知道为什么会这么做.

任何帮助都受到高度赞赏

干杯
Anand



Dont'' understand why it is doing so.

Any help is highly appreciated

Cheers
Anand

推荐答案

检查这些博客
http://stackoverflow.com/questions/4759579/winforms-combobox-selectedindexchanged-not-firing-何时键入以下几个字符 [ http://www.sitefinity.com/devnet/forums/sitefinity-3-x/3-x-pre-release-forums-retired/combobox-selectedindexchanged-event-does- not-fire-on-first-ajax-request.aspx [
check these blogs
http://stackoverflow.com/questions/4759579/winforms-combobox-selectedindexchanged-not-firing-when-typing-few-chars-followed[^]
http://www.sitefinity.com/devnet/forums/sitefinity-3-x/3-x-pre-release-forums-retired/combobox-selectedindexchanged-event-does-not-fire-on-first-ajax-request.aspx[^]
--NDK


此问题通过使用相同控件创建新表单得以解决.
看起来很傻,但是我的问题解决了.
现在一切正常.

干杯
Anand
This problem got solved by creating new form with the same controls.
Looks silly, but my problem is solved.
Now everthing works fine.

Cheers
Anand


这篇关于组合框onselectedindex更改了按钮控件的事件触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆