<asp:UpdatePanel ID="updPanel1" runat="server"> <ContentTemplate> <asp:DropDownList ID="ddlTest1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlTest1_IndexChanged"> <asp:ListItem Value="" Text="Select one"></asp:ListItem> <asp:ListItem Value="Matt" Text="Matt"></asp:ListItem> <asp:ListItem Value="Robin" Text="Robin"></asp:ListItem> </asp:DropDownList> <asp:DropDownList ID="ddlTest2" runat="server" style="visibility:hidden;display:none;"> <asp:ListItem Text="Select One" Value=""></asp:ListItem> <asp:ListItem Text="Tom" Value="Tom"></asp:ListItem> <asp:ListItem Text="John" Value="John"></asp:ListItem> </asp:DropDownList> </ContentTemplate> </asp:UpdatePanel>
Protected Sub ddlTest1_IndexChanged(ByVal sender As Object, ByVal e As EventArgs) If ddlTest1.SelectedValue = "Robin" Then Dim script As String = "<script type='text/javascript'>var elem=document.getElementById('" & Me.ddlTest2.ClientID & "');elem.style.visibility='visible';elem.style.display='block';</script> Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "newKeyVal", script, True) Else Dim script As String = "<script type='text/javascript'>var elem=document.getElementById('" & Me.ddlTest2.ClientID & "');elem.style.visibility='hidden';elem.style.display='block';</script>" Page.ClientScript.RegisterClientScriptBlock(Me.GetType (), "newKeyVal", script, True) End If End Sub
UpdateMode="Conditional"
Second Updatepanel
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)