我有一个 ASP.Net 下拉列表。When a certain value is selected, I want some line breaks to show up. 我正在使用 jQuery 执行此操作,因为我不知道如何使用 ASP.Net 选择换行符。问题是,我还有一个使用相同下拉列表触发的 UpdatePanel。他们可以一起工作吗?
ASP.NET:
<asp:DropDownList ID="ddlHowMany" runat="server"
onselectedindexchanged="ddlHowMany_SelectedIndexChanged"
style="margin-left: 8px" Width="50px" AutoPostBack="True" Height="22px">
</asp:DropDownList>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<br class="space" />
<br class="space" />
<asp:TextBox ID="txtGraphic1Desc" class="descriptions" runat="server" Height="92px"
TextMode="MultiLine"
Width="260px" Font-Names="Trebuchet MS" Visible="False">Description of graphic #1</asp:TextBox>
<br class="space" />
<br class="space" />
<asp:TextBox ID="txtGraphic2Desc" class="descriptions" runat="server" Height="92px"
TextMode="MultiLine"
Width="260px" Font-Names="Trebuchet MS" Visible="False">Description of graphic #2</asp:TextBox>
<br class="space" />
<br class="space" />
<asp:TextBox ID="txtGraphic3Desc" class="descriptions" runat="server" Height="92px"
TextMode="MultiLine"
Width="260px" Font-Names="Trebuchet MS" Visible="False">Description of graphic #3</asp:TextBox>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlHowMany" />
</Triggers>
</asp:UpdatePanel>
jQuery:
$.ajax({
url: "Default.aspx",
type: 'POST',
complete: function () {
if ($('#<%=ddlHowMany.ClientID %> option:selected').val() != "0") {
$('br.space').css({ display: 'block' });
}
else {
$('br.space').css({ display: 'none' });
}
}
})