ASP:UpdatePanel和SelectedIndexChanged无法触发 [英] ASP:UpdatePanel and SelectedIndexChanged not firing

查看:118
本文介绍了ASP:UpdatePanel和SelectedIndexChanged无法触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我手上有一个最烦人的问题.我有以下代码:

I have a most annoying issue on my hands. I have the following code:

<asp:UpdatePanel ID="upDetails" runat="server" ChildrenAsTriggers="true" UpdateMode="Always">
                <ContentTemplate>
                    <div class="main">
<asp:DropDownList id="myDDL" AutoPostBack="True" OnSelectedIndexChanged="myDDL_SelectedIndexChanged" runat="server />
</div>
</ContentTemplate>
</asp:UpdatePanel>



我在相关事件的代码中有一个断点,但是它从未被击中.请尽可能提供帮助.

预先感谢,
-Dom



I have a break point in my code on the relevant event, but it never gets hit. PLease help if possible.

Thanks in advance,
-Dom

推荐答案

检查我的示例,效果很好...

check my example, works fine...

<asp:scriptmanager id="ScriptManager1" runat="server" xmlns:asp="#unknown">
    </asp:scriptmanager>
    
    <asp:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">
        <contenttemplate>
            <asp:dropdownlist id="DropDownList1" runat="server" autopostback="true">
            </asp:dropdownlist>
            <br />            
            <asp:literal id="Literal1" runat="server"></asp:literal>
        </contenttemplate>        
    </asp:updatepanel>





code behind:

protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        //subscribe events
        this.Load += new EventHandler(_Default_Load);
        DropDownList1.SelectedIndexChanged += new EventHandler(DropDownList1_SelectedIndexChanged);        
    }

    void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Literal1.Text = "selected item: " + DropDownList1.SelectedItem;
    }

    void _Default_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            //initilizind drop down list
            List<string> list = new List<string>() { "item 1", "item 2", "item 3" };
            DropDownList1.DataSource = list;
            DropDownList1.DataBind();
        }
    }</string></string>


这篇关于ASP:UpdatePanel和SelectedIndexChanged无法触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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