如何禁用网格视图中的链接按钮
我有一个包含一些模板列的网格视图。在此,第一列包含名为“读取”的复选框,第四列和第五列包含 asp:link 按钮。如果用户单击读取复选框,则应启用两个链接按钮(最初处于禁用模式)。我使用这段 JavaScript 代码来禁用。但我没有得到解决方案。请帮助我实现这个解决方案。提前致谢..
function EnablePermissoin(chkB, cellNumber1, cellNumber2) {
var IsChecked = chkB.checked;
if (IsChecked) {
var cell = chkB.parentElement.parentElement.cells[cellNumber1];
for (i = 0; i < cell.childNodes.length; i++) {
if (cell.childNodes[i].type == "linkbutton") {
cell.childNodes[i].disabled = false;
}
}
}
}
<asp:TemplateColumn HeaderText="Read" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:CheckBox ID="chkRead" runat="server" Text='<%# Eval("Read") %>' onclick="javascript:EnablePermissoin(this,5,6);" />
</ItemTemplate>
</asp:TemplateColumn>
I have one grid view that contains some template columns. In this, the first column contains check boxes named as Read, fourth and fifth column contains asp:link button. If the user clicks on the read check box, both link buttons should be enabled (Initially it is in disabled mode). I used this JavaScript code for disabling. But i didn't get the solution. Please help me for acheiving this solution. Thanks in advance..
function EnablePermissoin(chkB, cellNumber1, cellNumber2) {
var IsChecked = chkB.checked;
if (IsChecked) {
var cell = chkB.parentElement.parentElement.cells[cellNumber1];
for (i = 0; i < cell.childNodes.length; i++) {
if (cell.childNodes[i].type == "linkbutton") {
cell.childNodes[i].disabled = false;
}
}
}
}
<asp:TemplateColumn HeaderText="Read" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:CheckBox ID="chkRead" runat="server" Text='<%# Eval("Read") %>' onclick="javascript:EnablePermissoin(this,5,6);" />
</ItemTemplate>
</asp:TemplateColumn>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
链接按钮呈现为锚点 (a) 标记是 java 脚本。所以你需要将脚本的一部分修改为
Linkbutton is rendered as anchor (a) tag is java-script. So you need to modify part of your script as
你可以试试这个,效果很好。
You can try this is working fine.