English 中文(简体)
排在同一个网页上,带电灯。 NET
原标题:posting to the same page with query string ASP.NET

我的问题是,在网页上任何纽芬兰人点击事件之前,这页的火力。 如果我想回到同一页,并在问询中转交一些数据,那么,就在第1页。 Load读到该数据和人口网格,视盘点的价值而定(细节.aspx =>细节.aspx?id=2)。

我如何能够这样做? 谢谢!

问题回答
private void Page_Load()
{
    if (IsPostBack)
    {
        // DO what you need to do from the postback here.
    }
}

最新资料:

if you use are redirecting to the page it is no longer a postback (Response.Redirect). In that case the option I see is in page_load you check for a specific querystring parameter and act on it.

  if(!String.IsNullOrEmpty(Convert.ToString(Request.QueryString["myQueryParam"])))
  {


  }

The Request.Form.Keys collection contains the button id that caused the postback. In effect you can use this to detect the button that was clicked.
Alternatively use ASP hyperlink control and put the querystring url into the NavgateUrl property. (unless you have more postback data required from the details page)

如果你正在做数据,对这样的工作具有约束性,那么你就会工作。

<asp:HyperLink ID=”linkTest1” runat=”server” NavigateUrl= <%# Eval(“ColumnName”, “Details.aspx?ID={0}”)  %>

Or you can set the ID from code behind like ths

linkTest.NavigateUrl = "Details.aspx?ID=" + IdVariable;

This would be better than doing the response.redirect

他似乎只是简单地问他如何用问话向同一页。 我感到惊讶的是,为什么没有人提到:

 void Page_Load( ... )
    {
        if (!Page.IsPostBack)
        {                
          Response.Redirect("Details.aspx?id=2");
        }
    }

当然,根据你的解释,我只字不提URL。 你们能够以方案方式确定这种ur和 que。

希望有助于其他人。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签