我运行一个页面就报这个错,就仅仅一个页面,不和数据库打交道,我在button按钮里调用js方法是能运行的,一旦用了onclick就报错:
CS1061: “ASP.login_aspx”不包含“showAll”的定义,并且找不到可接受类型为“ASP.login_aspx”的第一个参数的扩展方法“showAll”(是否缺少 using 指令或程序集引用?)
----------------------------------------------------
<script type="text/javascript">
function showAll()
{
var uname=document.getElementById("TextBox1");
var upwd=document.getElementById("TextBox2");
if(uname==null)
{
alert("请输入用户名!");
}
if(upwd==null)
{
alert("请输入密码!");
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 608px" align="center" class="aso">
<asp:TextBox ID="TextBox1" runat="server"
style="z-index: 1; left: 508px; top: 382px; position: absolute"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"
style="z-index: 1; left: 508px; top: 435px; position: absolute; width: 150px;"
TextMode="Password"></asp:TextBox>
<asp:Button ID="Button1" runat="server" style="z-index: 1; left: 722px; top: 434px; position: absolute" Text="登 录" OnClick="showAll()"/>
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/login.jpg" CssClass="cc"/>
</div>
</form>
</body>
CS1061: “ASP.login_aspx”不包含“showAll”的定义,并且找不到可接受类型为“ASP.login_aspx”的第一个参数的扩展方法“showAll”(是否缺少 using 指令或程序集引用?)
----------------------------------------------------
<script type="text/javascript">
function showAll()
{
var uname=document.getElementById("TextBox1");
var upwd=document.getElementById("TextBox2");
if(uname==null)
{
alert("请输入用户名!");
}
if(upwd==null)
{
alert("请输入密码!");
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 608px" align="center" class="aso">
<asp:TextBox ID="TextBox1" runat="server"
style="z-index: 1; left: 508px; top: 382px; position: absolute"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"
style="z-index: 1; left: 508px; top: 435px; position: absolute; width: 150px;"
TextMode="Password"></asp:TextBox>
<asp:Button ID="Button1" runat="server" style="z-index: 1; left: 722px; top: 434px; position: absolute" Text="登 录" OnClick="showAll()"/>
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/login.jpg" CssClass="cc"/>
</div>
</form>
</body>
解决方案 »
- asp.net 如何将FileUpload选中的图片存到sql2005数据库
- 检测是否联网代码、 IP如何配置app.config
- 请教Ajax的用法
- 想买本VS2005的书,(有案例的),请各位兄弟姐妹帮我介绍本??
- 大侠们,求求你们了,帮忙详细说一下gridview控件中显示文本的换行方法,不胜感激!
- 各位兄弟,我想实现像126信箱那样的多文件附件上传功能,怎么实现?
- 关于权限管理的界面问题
- 水晶报表的发布问题?我做好了个网站,但是找不到水晶报表的可发性主键老是出问题,请问各位高手能否提供水晶报表的可发性主键的下载地址
- 如何调用自定义控件
- 如何绑定datagrid中的dropdownlist?在线等
- 编译报错,高手指教
- 把TreeView 的节点存入TreeNodeCollection 怪异问题...麻烦大家看看..【抱歉,没分了】
OnClientClick="showAll()"
换这个
<input class="submit2" runat="server" value="登 录" onclick="showAll()" type="button" name="Submit3" />
试试。
OnClick这个用在普通HTML标答就是JS单击事件,在服务器控件上,就是控件单击事件,在后台。CS
写事件的,不是JS事件了。。
或者直接把OnClick改onclick,也可以试试也有可能是OnClick="showAll()" ->
OnClientClick="showAll()"
;
多试几个就知道了,方法多种多样。