源码如下:
<script language="c#" runat="server">
private void Page_Load(object sender,System.EventArgs e)
{
if(Page.IsPostBack)
{ if(Title.Text.Trim()=="")
{
Response.Write("<script language=javascript>alert('请填入文章标题 !!')</script> ");
}
else if(UserName.Text.Trim()==""){Response.Write();}
else if(WebAddress.Text.Trim()=="" ){Response.Write();}
else if(Email.Text.Trim()=="" ){Response.Write();}
else if(QQ.Text.Trim()==""){Response.Write();}
else if(Where.Text.Trim()==""){Response.Write();}
else if(Aticle.Text.Trim()==""){Response.Write();}
else{
string strTitle=Title.Text.Trim().ToString();
string strUserName=UserName.Text.Trim().ToString();
string strWebAddress=WebAddress.Text.Trim().ToString();
string strEmail=Email.Text.Trim().ToString();
string strQQ=QQ.Text.Trim().ToString();
string strWhere=Where.Text.Trim().ToString();
string strAticle=Aticle.Text.Trim().ToString();
string strInsert="";
string Mycon="";
SqlCommand strCom = new SqlCommand(strInsert,Mycon);
Mycon.Open();
strCom.ExecuteNonQuery();
Mycon.Close();
Response.Write();
}
}}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form runat="server"><table width="700" border="1" align="center" bordercolor="#000000" bgcolor="#CCCCCC">
<tr>
<td height="31" colspan="2"><div align="left">>>>填写留言:</div></td>
</tr>
<tr>
<td width="148" height="30"><div align="right">主题:</div></td>
<td width="536" height="30"><asp:TextBox ID="Title" runat="server" TextMode="SingleLine" /></td>
</tr>
<tr>
<td height="30"><div align="right">姓名:</div></td>
<td height="30"><asp:TextBox ID="UserName" Height="30" runat="server" TextMode="SingleLine" /></td>
</tr>
<tr>
<td height="30"><div align="right">主页地址:</div></td>
<td height="30">
http://
<asp:TextBox ID="WebAddress" Height="30" runat="server" TextMode="SingleLine" /> </td>
</tr>
<tr>
<td height="30"><div align="right">电子邮件:</div></td>
<td height="30">
<asp:TextBox ID="Email" Height="30" runat="server" TextMode="SingleLine" /> </td>
</tr>
<tr>
<td height="30"><div align="right">QQ号码:</div></td>
<td height="30">
<asp:TextBox TextMode="SingleLine" ID="QQ" Height="30" runat="server" />
</td>
</tr>
<tr>
<td height="30"><div align="right">来自那里:</div></td>
<td height="30">
<asp:TextBox ID="Where" Height="30" runat="server" TextMode="SingleLine" /> </td>
</tr>
<tr>
<td height="107"><div align="right">留言内容:</div></td>
<td>
<asp:TextBox Height="107" ID="Aticle" runat="server" TextMode="MultiLine" Width="536" Wrap="true" /> </td>
</tr>
<tr>
<td height="32" colspan="2">
<div align="center">
<asp:Button ID="Button2" runat="server" Text="提交" BorderStyle="solid" />
<asp:Button ID="Button3" Text="重写" runat="server" />
<asp:Button ID="Button1" runat="server" Text="返回" /> </div>
<div align="center"></div> </td>
</tr>
<tr bgcolor="#666666">
<td height="60" colspan="2"> 1)留言者不能发布任何不符合当地法规、国家法律和国际法律的资料; <br>
2)留言者不得发布任何非法的、骚扰性的、中伤他人的、辱骂性的、恐吓性的、伤害性的、庸俗的,淫秽等信息资料; </td>
</tr>
</table></form>
</body>
</html>
<script language="c#" runat="server">
private void Page_Load(object sender,System.EventArgs e)
{
if(Page.IsPostBack)
{ if(Title.Text.Trim()=="")
{
Response.Write("<script language=javascript>alert('请填入文章标题 !!')</script> ");
}
else if(UserName.Text.Trim()==""){Response.Write();}
else if(WebAddress.Text.Trim()=="" ){Response.Write();}
else if(Email.Text.Trim()=="" ){Response.Write();}
else if(QQ.Text.Trim()==""){Response.Write();}
else if(Where.Text.Trim()==""){Response.Write();}
else if(Aticle.Text.Trim()==""){Response.Write();}
else{
string strTitle=Title.Text.Trim().ToString();
string strUserName=UserName.Text.Trim().ToString();
string strWebAddress=WebAddress.Text.Trim().ToString();
string strEmail=Email.Text.Trim().ToString();
string strQQ=QQ.Text.Trim().ToString();
string strWhere=Where.Text.Trim().ToString();
string strAticle=Aticle.Text.Trim().ToString();
string strInsert="";
string Mycon="";
SqlCommand strCom = new SqlCommand(strInsert,Mycon);
Mycon.Open();
strCom.ExecuteNonQuery();
Mycon.Close();
Response.Write();
}
}}
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>
<body>
<form runat="server"><table width="700" border="1" align="center" bordercolor="#000000" bgcolor="#CCCCCC">
<tr>
<td height="31" colspan="2"><div align="left">>>>填写留言:</div></td>
</tr>
<tr>
<td width="148" height="30"><div align="right">主题:</div></td>
<td width="536" height="30"><asp:TextBox ID="Title" runat="server" TextMode="SingleLine" /></td>
</tr>
<tr>
<td height="30"><div align="right">姓名:</div></td>
<td height="30"><asp:TextBox ID="UserName" Height="30" runat="server" TextMode="SingleLine" /></td>
</tr>
<tr>
<td height="30"><div align="right">主页地址:</div></td>
<td height="30">
http://
<asp:TextBox ID="WebAddress" Height="30" runat="server" TextMode="SingleLine" /> </td>
</tr>
<tr>
<td height="30"><div align="right">电子邮件:</div></td>
<td height="30">
<asp:TextBox ID="Email" Height="30" runat="server" TextMode="SingleLine" /> </td>
</tr>
<tr>
<td height="30"><div align="right">QQ号码:</div></td>
<td height="30">
<asp:TextBox TextMode="SingleLine" ID="QQ" Height="30" runat="server" />
</td>
</tr>
<tr>
<td height="30"><div align="right">来自那里:</div></td>
<td height="30">
<asp:TextBox ID="Where" Height="30" runat="server" TextMode="SingleLine" /> </td>
</tr>
<tr>
<td height="107"><div align="right">留言内容:</div></td>
<td>
<asp:TextBox Height="107" ID="Aticle" runat="server" TextMode="MultiLine" Width="536" Wrap="true" /> </td>
</tr>
<tr>
<td height="32" colspan="2">
<div align="center">
<asp:Button ID="Button2" runat="server" Text="提交" BorderStyle="solid" />
<asp:Button ID="Button3" Text="重写" runat="server" />
<asp:Button ID="Button1" runat="server" Text="返回" /> </div>
<div align="center"></div> </td>
</tr>
<tr bgcolor="#666666">
<td height="60" colspan="2"> 1)留言者不能发布任何不符合当地法规、国家法律和国际法律的资料; <br>
2)留言者不得发布任何非法的、骚扰性的、中伤他人的、辱骂性的、恐吓性的、伤害性的、庸俗的,淫秽等信息资料; </td>
</tr>
</table></form>
</body>
</html>
行 12: Response.Write("<script language=javascript>alert('请填入文章标题 !!')</script> ");把它写为一行
Response.Write("<script language=javascript>alert('请填入文章标 !!');</script> ");
<!--
window.alert('请填入文章标题 !!');
//-->
</script>");
===================================================================Response.Write("<script>alert('请填入文章标题 !!')</script>");
==================================================================
以上两种都可以
wxlada(绿茶):
我在DW里式写成一行的啊
试试看:
Response.Write("<script language=javascript>alert('请填入文章标题 !!')</"+"script> ");