ajax部分页面渲染可以应用于html select标签吗? [英] does ajax partial page rendering can be applied on html select tag?

查看:82
本文介绍了ajax部分页面渲染可以应用于html select标签吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

能否将AJAX部分页面呈现功能应用于HTML选择标记?
如果支持,请提供示例代码.

Can AJAX partial page rendering be applied on a HTML select tag?
If it is suppored, then please provide a sample code.

推荐答案

是的,但是我会使用asp:DropDownList控件.
Yes, but I would use the asp:DropDownList control.
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:DropDownList runat="server" ID="DropDownList1" AutoPostBack="true">
            <asp:ListItem>Item 1</asp:ListItem>
            <asp:ListItem>Item 2</asp:ListItem>
        </asp:DropDownList>
        <asp:Label runat="server" ID="Label1" />
    </ContentTemplate>
</asp:UpdatePanel>

protected void Page_Init(object sender, EventArgs e)
{
    this.DropDownList1.SelectedIndexChanged += new EventHandler(DropDownList1_SelectedIndexChange);
}
protected void DropDownList1_SelectedIndexChange(object sender, EventArgs e)
{
    this.Label1.Text = (this.DropDownList1.SelectedItem != null) ? "You selected: " + this.DropDownList1.SelectedItem.Value : "";
}


这篇关于ajax部分页面渲染可以应用于html select标签吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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