复制代码 代码如下:
protected void Page_Load(object sender, EventArgs e)
{
var condition = ......;
if (!condition)
{
Response.Redirect("SomePage.aspx");
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
// Save Data Here
}
复制代码 代码如下:
public static class HttpResponseExtensions
{
public static void RedirectUser(this HttpResponse response, string url)
{
if (response.IsRequestBeingRedirected)
return;
response.Redirect(url, false);
var context = HttpContext.Current;
if (context != null)
{
context.ApplicationInstance.CompleteRequest();
}
}
}
public partial class WebForm : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
var condition = .....;
if (!condition)
{
Response.RedirectUser("Unauthorized.aspx");
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
if (Response.IsRequestBeingRedirected)
{
return;
}
// Save Data Here
}
}
复制代码 代码如下:
<form runat="server">
<% if(!Response.IsRequestBeingRedirected){ %>
<asp:Button runat="server" Text="Save" />
<%--All the Other Controls--%>
<%--All the Other Controls--%>
<%--All the Other Controls--%>
<%} %>
</form>
复制代码 代码如下:
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
if (Response.IsRequestBeingRedirected)
{
e.Cancel = true;
return;
}
}
新闻热点
疑难解答
图片精选