我想禁用ASP.net页面中使用JavaScript的控件 [英] I want to disable controls using JavaScript in ASP.net pages

查看:75
本文介绍了我想禁用ASP.net页面中使用JavaScript的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的asp.net页面中,我有1个按钮,1个文本框,1个标签和1个Checkbok.当我选中该复选框时,将使用JAVASCRPIT禁用其余控件.

In my asp.net page I have 1 button, 1 textbox ,1 label and 1 checkbok. When I check the checkbox remaining controls will be disable by using JAVASCRPIT.

推荐答案

use that 
document.getElementById('<%=TextboxId.ClientID%>').disable=true;


1. 将"OnClientClick"事件处理程序添加到按钮控件,并让其调用将启用/禁用控件的javascript函数.

2.
使用客户端ID(而不是服务器ID)并使用getElementById(''yourclientid'')函数来获取控件句柄并启用/禁用该控件.
如果您无法通过代码(在标记或后面的代码中)进行设置,请加载页面并查看源代码.客户端ID在那里(尽管那里应该有更好的解决方案)

希望对您有所帮助.
1. Add the "OnClientClick" eventhandler to the button control and let it call the javascript function that will enable/disable the controls.

2.
Use the client ID (not the server id) and use the getElementById(''yourclientid'') function to get the control handle and enable/disable that control.
In case you can''t set it through code (in the markup or code behind), load up the page and do view source. The client id''s are there (although there should be a nicer solution around there)

Hope this helps.


您好..
用这个

Hi there..
use this

var control=document.getElementById("ButtonId");
control.disabled=true;



一切顺利.



all the best..


这篇关于我想禁用ASP.net页面中使用JavaScript的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆