第一种
Page.ClientScript.RegisterStartupScript和Page.ClientScript.RegisterClientScriptBlock
if
(txtUsername.Text.Trim()
==
string
.Empty)
{
Page.ClientScript.RegisterStartupScript( this .GetType(), "" , " alert('收货人,不能为空!'); " , true );
return ;
}
{
Page.ClientScript.RegisterStartupScript( this .GetType(), "" , " alert('收货人,不能为空!'); " , true );
return ;
}
第二种
Response.Write("<script>alert('收货人,不能为空!');history.go(-1);</script>");
如果缺少 history.go(-1); 样式会乱掉。
if
(txtUsername.Text.Trim()
==
string
.Empty)
{
Response.Write( " <script>alert('收货人,不能为空!');history.go(-1);</script> " );
return ;
}
{
Response.Write( " <script>alert('收货人,不能为空!');history.go(-1);</script> " );
return ;
}