gpt4 book ai didi

使用 javascript 的 ASP.net 隐藏面板

转载 作者:行者123 更新时间:2023-11-29 10:25:30 25 4
gpt4 key购买 nike

我有一个包含 2 个项目的 radioButtonList。具有"is"值的单选按钮和具有“否”值的 radionButton。

Below that I have a panel which I want made visible when "Yes"radioButton is selected and hidden when "No"is selected.我最初是使用 AutoPostBack 属性实现的,但我想用 Javascript 实现它,这样它就不会导致回发。这是代码。任何帮助将不胜感激。

<asp:RadioButtonList ID="rbl1" runat="server" onClick="changed(this);" >
<asp:ListItem Value="Yes">Yes</asp:ListItem>
<asp:ListItem Value="No">No</asp:ListItem>

<asp:Panel ID="panel1" runat="server">
<--other controls here -->
</asp:Panel>

function changed(rbl) {
//not sure what to put in here
}

提前致谢

闪电

最佳答案

这是我编写的一个简单示例:

<!-- Used grouped radio buttons instead of the RadioButtonList as it is harder to deal with -->
<asp:RadioButton ID="rbYes" runat="server" Text="Yes" GroupName="YourGroupName" Checked="true" />
<asp:RadioButton ID="rbNo" runat="server" Text="No" GroupName="YourGroupName" />
<br /><br />
<!-- Use a div instead of a panel. Panels are just glorified divs. -->
<div id="divTest">
This is a test
</div>

<script type="text/javascript">
$(document).ready(function()
{
$('#<%= rbYes.ClientID %>').click(function() { $('#divTest').show(); });
$('#<%= rbNo.ClientID %>').click(function() { $('#divTest').hide(); });

});
</script>

关于使用 javascript 的 ASP.net 隐藏面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2433592/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com