具有下拉列表的AJAX更新面板 [英] AJAX UPDATE PANEL WITH DROPDOWN LIST

查看:82
本文介绍了具有下拉列表的AJAX更新面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码:dropdownlist在updatepanel里面



my code : dropdownlist is inside updatepanel

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
 <contenttemplate>
  <asp:DropDownList ID="dropboard" runat="server" CssClass="dropclass" OnSelectedIndexChanged="dropboard_SelectedIndexChanged">
                                               
                                                <asp:ListItem>State Board
                                                <asp:ListItem>Intermediate
                                                <asp:ListItem>Central Board
                                                <asp:ListItem>Others
                                                <asp:ListItem>Not Applicable
 
         </contenttemplate>    
 <triggers>
        <asp:AsyncPostBackTrigger controlid="dropboard" EventName="SelectedIndexChanged" />
    </triggers>





如果我在下拉列表中选择其他文本框应该是可见的。但它不起作用。



If i select others in dropdownlist textbox should be visible. But its not working.

推荐答案

取决于。你的TextBox在哪里?尝试将文本框放在更新面板中。而且,我找不到 AutoPostBack =true您的下拉列表的属性。尝试添加它。

尝试这样:

HTML:

Depends. Where is your TextBox? Try putting your textbox in update panel. And also, I can''t find AutoPostBack="true" property of your dropdownlist. Try adding that.
Try like this:
HTML:
<asp:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">
    <contenttemplate>
        <asp:dropdownlist id="DropDownList1" runat="server">
            onselectedindexchanged="DL1_SelectedIndexChanged" AutoPostBack="true">
            <asp:listitem></asp:listitem>
            <asp:listitem>Others</asp:listitem>
        </asp:dropdownlist>
        <asp:textbox id="TextBox1" runat="server" visible="false">
    </asp:textbox></contenttemplate> 
</asp:updatepanel>



Code Behind:


Code Behind:

Protected Sub DL1_SelectedIndexChanged(sender As Object, e As EventArgs)
    If DropDownList1.SelectedItem.Text = "Others" Then
        TextBox1.Visible = True
        Else
                TextBox1.Visible= False
    End If
End Sub





--Amit



--Amit


是的,您应该在更新面板中放置带触发器的文本框

yes, You should place textbox in update panel with trigger
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
  <ContentTemplate>
   <asp:Textbox ID="opstock" runat="server"></asp:Textbox>
                                                                            </ContentTemplate>
   <Triggers>
                                                                               <asp:AsyncPostBackTrigger ControlID="dropdown" EventName="SelectedIndexChanged" />
                                                                            </Triggers>
                                                                       </asp:UpdatePanel>





并使用 autopostback属性true dropboard(下拉列表)



and use Autopostback property true of dropboard (dropdownlist)


这篇关于具有下拉列表的AJAX更新面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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