读书人

vs2005里WebUserControl的有关问题

发布时间: 2012-01-14 20:02:35 作者: rapoo

vs2005里WebUserControl的问题
<script runat= "server ">
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == " " || TextBox2.Text == " ")
{
alert( '用户名密码不能为空 ');
}
else
{
alert( '用户名或密码错误 ');
}
}
</script>

这么写的按钮单击事件

提示错误

Error 17Too many characters in character literal



[解决办法]
<script runat= "server ">
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == " " || TextBox2.Text == " ")
{
alert( '用户名密码不能为空 ');
}
else
{
alert( '用户名或密码错误 ');
}
}
</script>
===============================================
不明白你的代码到底是js代码,还是c#代码。

如果是js的话:
<script runat= "server ">
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == " " || TextBox2.Text == " ")
{
Response.Write( " <script> javascript:window.alert( '用户名密码不能为空 '! '); </script> ");
}
else
{
Response.Write( " <script> javascript:window.alert( '用户名或密码错误 ' '! '); </script> ");
}
}
</script>

另外:你的“else块”逻辑判断有错误。
[解决办法]
<script runat= "server ">
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == " " || TextBox2.Text == " ")
{
alert( '用户名密码不能为空 ');
}
else
{
alert( '用户名或密码错误 ');
}
}
</script>
===============================================
不明白你的代码到底是js代码,还是c#代码。

如果是c#的话:(刚才打印错了!)
<script runat= "server ">
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == " " || TextBox2.Text == " ")
{
Response.Write( " <script> javascript:window.alert( '用户名密码不能为空 '! '); </script> ");
}
else
{
Response.Write( " <script> javascript:window.alert( '用户名或密码错误 ' '! '); </script> ");
}
}
</script>

另外:你的“else块”逻辑判断有错误。

读书人网 >asp.net

热点推荐