如何在 asp.net 中使用 JavaScript 禁用链接按钮或隐藏链接按钮
我有这样的代码:
function rdLoanChecked() {
var isCheckedInstallment = $find("<%= rdMonthlyInstallment.ClientID %>").get_checked();
var isCheckedLoanAmount = $find("<%= rdLoanAmount.ClientID %>").get_checked();
if (isCheckedLoanAmount) {
document.getElementById('<%= btRecalculateByLoan.ClientID %>').style.display = "none";
document.getElementById('<%= btCalculateByInstallment.ClientID %>').style.display = "none";
document.getElementById('<%= btRecalculateByInstallment.ClientID %>').style.display = "none";
document.getElementById('<%= btnext.ClientID %>').style.display = "none";
document.getElementById('<%= btCalculateByLoan.ClientID %>').style.display = "inline";
}
else if (isCheckedInstallment) {
document.getElementById('<%= btRecalculateByLoan.ClientID %>').style.display = "none";
document.getElementById('<%= btCalculateByInstallment.ClientID %>').style.display = "none";
document.getElementById('<%= btRecalculateByInstallment.ClientID %>').style.display = "none";
document.getElementById('<%= btnext.ClientID %>').style.display = "inline";
document.getElementById('<%= btCalculateByLoan.ClientID %>').style.display = "none";
}
<td width="5%" style="vertical-align: middle;">
<telerik:RadButton ID="rdLoanAmount" runat="server" ButtonType="ToggleButton" Text=""
OnClientCheckedChanged="rdLoanChecked" CssClass="rdLoanAmount"
ToggleType="Radio" GroupName="rdCalculationBy" BorderStyle="None">
</telerik:RadButton>
</td>
<td style="vertical-align: middle;">
<cc1:LocalizedLabel ID="lblLoanAmount" runat="server" Key="lblLoanAmount"></cc1:LocalizedLabel>
</td>
<td style="vertical-align: top;" width="5%">
<telerik:RadButton ID="rdMonthlyInstallment" runat="server" ButtonType="ToggleButton"
OnClientCheckedChanged="rdLoanChecked" CssClass="rdMonthlyInstallment"
Text="" ToggleType="Radio" GroupName="rdCalculationBy" BorderStyle="None">
</telerik:RadButton>
</td>
我需要隐藏或显示一些带有条件单选按钮的链接按钮(在本例中单选按钮radbutton telerik
)。
这段代码不起作用。
I have code like this:
function rdLoanChecked() {
var isCheckedInstallment = $find("<%= rdMonthlyInstallment.ClientID %>").get_checked();
var isCheckedLoanAmount = $find("<%= rdLoanAmount.ClientID %>").get_checked();
if (isCheckedLoanAmount) {
document.getElementById('<%= btRecalculateByLoan.ClientID %>').style.display = "none";
document.getElementById('<%= btCalculateByInstallment.ClientID %>').style.display = "none";
document.getElementById('<%= btRecalculateByInstallment.ClientID %>').style.display = "none";
document.getElementById('<%= btnext.ClientID %>').style.display = "none";
document.getElementById('<%= btCalculateByLoan.ClientID %>').style.display = "inline";
}
else if (isCheckedInstallment) {
document.getElementById('<%= btRecalculateByLoan.ClientID %>').style.display = "none";
document.getElementById('<%= btCalculateByInstallment.ClientID %>').style.display = "none";
document.getElementById('<%= btRecalculateByInstallment.ClientID %>').style.display = "none";
document.getElementById('<%= btnext.ClientID %>').style.display = "inline";
document.getElementById('<%= btCalculateByLoan.ClientID %>').style.display = "none";
}
<td width="5%" style="vertical-align: middle;">
<telerik:RadButton ID="rdLoanAmount" runat="server" ButtonType="ToggleButton" Text=""
OnClientCheckedChanged="rdLoanChecked" CssClass="rdLoanAmount"
ToggleType="Radio" GroupName="rdCalculationBy" BorderStyle="None">
</telerik:RadButton>
</td>
<td style="vertical-align: middle;">
<cc1:LocalizedLabel ID="lblLoanAmount" runat="server" Key="lblLoanAmount"></cc1:LocalizedLabel>
</td>
<td style="vertical-align: top;" width="5%">
<telerik:RadButton ID="rdMonthlyInstallment" runat="server" ButtonType="ToggleButton"
OnClientCheckedChanged="rdLoanChecked" CssClass="rdMonthlyInstallment"
Text="" ToggleType="Radio" GroupName="rdCalculationBy" BorderStyle="None">
</telerik:RadButton>
</td>
I need hide or display some linkbutton with condition radiobutton (in this case radiobutton radbutton telerik
).
This code not work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
从你“$find(...)”的外观来看,你似乎正在尝试使用 jQuery?如果是这样,请按如下方式更改变量声明的代码:
您需要告诉 jQuery 选择器您是否正在查找元素类型
$("element")
、元素 ID$(" #element")
或元素 CSS 类$(".element")
。您的变量声明假设您正在寻找元素类型(即类型为“<%= rdMonthlyInstallment.ClientID %>
”的标记),这是不正确的。您应该寻找元素 ID。By the looks of you "$find(...)" it seems like you're trying to use jQuery? If so, change the code of the variable declarations as follows:
You need to tell the jQuery selector whether you are looking for an element type
$("element")
, element ID$("#element")
or element CSS class$(".element")
. Your variable declaration assumed you are looking for an element TYPE (i.e. a tag of type "<%= rdMonthlyInstallment.ClientID %>
"), which is incorrect. You should be looking for an element ID.我认为一个问题是你总是将 display = "none" 设置为 btRecalculateByLoan、btCalculateByInstallment 和 btRecalculateByInstallment
I think a problem is that you always set display = "none" to the btRecalculateByLoan, btCalculateByInstallment and btRecalculateByInstallment