Click here to Skip to main content
16,018,818 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my code : dropdownlist is inside updatepanel

ASP.NET
<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.
Posted
Updated 19-Feb-13 17:23pm
v2

yes, You should place textbox in update panel with trigger
XML
<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>


and use Autopostback property true of dropboard (dropdownlist)
 
Share this answer
 
v2
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.NET
<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:
VB
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900