I am just getting started using the ASP.NET/Ajax extensions and am curious about something. I have an aspx page where the controls are laid out using a table...nothing unusual there. Two of the controls are asp:DropDownList controls. Each of the controls appears in a row <tr> of the enclosing <table>. I have the classic issue of having the selection of DropDown1 controlling the choices listed in DropDown2. I need then to put the DropDown2 in an UpdatePanel and wire them together. However, can you use the UpdatePanel INSIDE of the <table> around only those rows containing the control involved? Something like this...(I have not completed this yet...as I wanted to find out if this is even allowed).
<tr>
<td align="right">
<asp:Label ID="lblSYS_NM" runat="server" Text="System:"></asp:Label></td>
<td>
<asp:DropDownList ID="ddSYS_NM" runat="server" >
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvddSYS_NM" ControlToValidate="ddSYS_NM" InitialValue="0" Display="Dynamic" runat="server">
<%= RequestConstants.DDL_MSG %>
</asp:RequiredFieldValidator>
</td>
<td>
(Select System)</td>
</tr>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<tr>
<td align="right">
<asp:Label ID="lblSUB_SYS_NM" runat="server" Text="SubSystem:"></asp:Label></td>
<td>
<asp:DropDownList ID="ddSUB_SYS_NM" runat="server" AutoPostBack="False">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvddSUB_SYS_NM" ControlToValidate="ddSUB_SYS_NM" InitialValue="0" Display="Dynamic" Width="100%"
runat="server">
<%= RequestConstants.DDL_MSG %>
</asp:RequiredFieldValidator>
</td>
<td>
(Select SubSystem)</td>
</tr>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddSYS_NM" EventName="SelectedIndexChanged" />
</Triggers
</asp:UpdatePanel>
Thanks
I would only wrap the necessary controls with the update panel. The only thing that changes within the update panel is the DropDownLists. it would look more like this:
<table>
<tr>
<td><asp:Label... /></td>
<td>
<asp:DropDownList id="DropDown1" .../>
<asp:RequiredFieldValidator .../>
</td>
</tr>
<tr>
<td><asp:Label... /></td>
<td>
<asp:UpdatePanel ...>
<ContentTemplate>
<asp:DropDownList id="DropDown2" .../>
<asp:RequiredFieldValidator .../>
</ContentTemplate>
<Triggers>
<AysncPostBackTigger Control="DropDownList1" Event="Click" />
</Triggers>
</asp:UpdatePanel>
</td>
</tr>
</table>
No comments:
Post a Comment