asp.net中怎么让页面刷新加载?
usingSystem;usingSystem.Collections;usingSystem.Configuration;usingSystem.Data;usingS...
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class MessageBoard : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
if (TextBox1.Text == "" || TextBox2.Text == "")
{
Page.RegisterStartupScript("", "<script>alert('请输入留言主题和内容!');</script>");
}
else {
try {
string connstr=ConfigurationManager.ConnectionStrings["MessageConnectionString"].ConnectionString;
SqlConnection conn=new SqlConnection (connstr);
conn.Open();
SqlCommand cmd = new SqlCommand("dbo.proc_insertmessageinfo", conn);
cmd.CommandType=CommandType.StoredProcedure;
SqlParameter para2 = new SqlParameter("@heading", SqlDbType.NVarChar);
para2.Value = TextBox1.Text;
cmd.Parameters.Add(para2);
SqlParameter para3 = new SqlParameter("@content", SqlDbType.NVarChar);
para3.Value = TextBox2.Text;
cmd.Parameters.Add(para3);
SqlParameter para4 = new SqlParameter("@time", SqlDbType.DateTime);
para4.Value = DateTime.Now.ToShortDateString();
cmd.Parameters.Add(para4);
cmd.ExecuteNonQuery();
Page.RegisterStartupScript("","<script>alert('发表成功!');</script>");
conn.Close();
}
catch{
}
}
}
} 展开
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class MessageBoard : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
if (TextBox1.Text == "" || TextBox2.Text == "")
{
Page.RegisterStartupScript("", "<script>alert('请输入留言主题和内容!');</script>");
}
else {
try {
string connstr=ConfigurationManager.ConnectionStrings["MessageConnectionString"].ConnectionString;
SqlConnection conn=new SqlConnection (connstr);
conn.Open();
SqlCommand cmd = new SqlCommand("dbo.proc_insertmessageinfo", conn);
cmd.CommandType=CommandType.StoredProcedure;
SqlParameter para2 = new SqlParameter("@heading", SqlDbType.NVarChar);
para2.Value = TextBox1.Text;
cmd.Parameters.Add(para2);
SqlParameter para3 = new SqlParameter("@content", SqlDbType.NVarChar);
para3.Value = TextBox2.Text;
cmd.Parameters.Add(para3);
SqlParameter para4 = new SqlParameter("@time", SqlDbType.DateTime);
para4.Value = DateTime.Now.ToShortDateString();
cmd.Parameters.Add(para4);
cmd.ExecuteNonQuery();
Page.RegisterStartupScript("","<script>alert('发表成功!');</script>");
conn.Close();
}
catch{
}
}
}
} 展开
2个回答
展开全部
再加一句script代码会刷新页面
window.location .href =window.location .href;
window.location .href =window.location .href;
追问
当前上下文中不存在名称“window” 怎么引入window
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2012-05-06
展开全部
在
Page.RegisterStartupScript("","<script>alert('发表成功!');</script>");
下面加上这句
response.Redirect("你的页面.aspx");
Page.RegisterStartupScript("","<script>alert('发表成功!');</script>");
下面加上这句
response.Redirect("你的页面.aspx");
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询