你现在服务器端的代码都没有做任何动作,改成RUNAT="SERVER"肯定没效果了
解决方案 »
- webbrowser获取cookie,自动登录的图片验证
- 添加引用操作记录在哪里?
- 正则表达式求助
- AxWebBrowser的NewWindow2,NewWindow的触发顺序???
- 请问大家在项目中如果遇到数据库内容为图片时怎么办
- 莫名其妙的错误:在我添加类和方法的时候,出现的错误提示“目录没有写权限”
- 刚建一.net c#群,号:5617862
- C#调用VC++编写的DLL,出现Access Violations问题
- 在WEB Form中的保留不了值!
- 求1个NPOI最新版本DLL下载
- datagridview 数据库中时间格式数据显示问题
- 希望大家推荐一本好的ASP.NET的书,编程语言为C#
<asp:button id="bt_Employee" runat="server" Width="24px" Text="...">
//frm=document.forms[0]
if(!document.getElementById('cbox').checked)
{document.getElementById('Button1').disabled=true}
else {document.getElementById('Button1').disabled=false}
}
写错了
楼主写的是当多选框选中时候启用Button1
没有选中的时候禁用Button1如果确实是这个效果
经过试验代码没有问题
===========================================================================================
网页脚本错误用户代理: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; CIBA; IE7Pro)
时间戳: Tue, 13 Jan 2009 04:18:06 UTC消息: 'document.getElementById(...)' 为空或不是对象消息: 对象不支持此属性或方法
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title> <script language="JavaScript">
function Disab() {
//frm=document.forms[0]
if(!document.getElementById('cbox').checked)
{document.getElementById('Button1').disabled=true}
else {document.getElementById('Button1').disabled=false}
}
</script></head>
<body>
<form id="form1" runat="server">
<div align="center">
<input name="cbox" type="checkbox" id="cbox" value="checkbox" onclick="Disab();">
Click here to Enable/Disable Button</div>
<p align="center">
<input type="button" runat="server" disabled="disabled" value="Button" name="Button1" id="Button1" onserverclick="Button1_ServerClick">
</form>
</body>
</html>WebForm1.aspx.cs
using System;namespace Web
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_ServerClick(object sender, EventArgs e)
{
Response.Write("点击了 Button1");
} }
}
哈哈
老实交代,你的button是不是放在一个用户控件里了服务端控件是会在客户端生成ClientId的,这个id才是并不会一定是 button1 了
function Disab( btnid ) {
//frm=document.forms[0]
if(!document.getElementById('cbox').checked)
{document.getElementById(btnid).disabled=true}
else {document.getElementById(btnid).disabled=false}
}页面的page_load代码:
protected void Page_Load(object sender, EventArgs e)
{
Button1.Attributes["onclick"] = string.Format("Disab('{0}')",Button1.ClientId);
}