vs2005里WebUserControl的问题
<script runat= "server ">
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text == " " || TextBox2.Text == " ")
{
alert( '用户名密码不能为空 ');
}
else
{
alert( '用户名或密码错误 ');
}
}
</script>
这么写的按钮单击事件
提示错误
Error 17 Too 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块”逻辑判断有错误。