English 中文(简体)
下载页数活动
原标题:Triggering of pageload event
  • 时间:2012-01-13 04:37:03
  •  标签:
  • asp.net

我有不同的事件,例如检查箱改变了事件,把点击事件联系起来。 在点击其中的任何部分时,页面负荷活动也触发了触发事件。 当我引发其他事件时,我不想引发页数事件。 帮助我防止在引发其他事件时引发页数事件。

问题回答

不幸的是,Load事件总是会火上。 这是因为,该网页在服务器上装满。 它是伙伴关系的一部分。 NET 网页生命周期。

然而,如果你想要在Load页活动中做些什么,那页数第一次被击中,但比起任何其他时间,你可以用该页在一份发言中总结这一功能。 收回财产。 当你首次上页时,IsPostback财产就会是假的,但当你的任何县、联系等造成后退时,这种财产将属实。

例,如VB。 NET

If Not Page.IsPostBack Then
  Code that is to be executed when the page is first hit goes here
End If

在“PostBack”检查中将该代码放在“有效载荷”网页上。

C#例

protected void page_load()

{

if(!isPostBack)

{

.........//Your

.........//code here

}

}

And of course write the code that you want to execute, when the event gets triggered, inside the event Click of the respective control. Hope that helps.





相关问题
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!

热门标签