English 中文(简体)
利用IPostBack 1. 简历
原标题:Using IPostBackEventHandler on a Masterpage

I ve used IPostBackEventHandler on pages in past for打 RaisePostBackEvent,载于我通过<代码>javascript登出的代码。

目前,我正在从事一个项目,该项目需要同样的功能,但如果我能将其放在我的<代码>MasterPage<<>/code>上的话,那么,我会同样地尝试该项目,但我没有幸运,我想知道有人是否能够把我放在标准上。

声明:

public partial class Master_Pages_MainMasterPage : System.Web.UI.MasterPage, IPostBackEventHandler
{
   public void RaisePostBackEvent(string eventArgument)
    {
       // do stuff
    }
}

My Javascript:

function myFunction{
  var pageId =  <%= Page.ClientID %> ;

  __doPostBack(pageId,  savePageContent );
}

My test page :

public partial class TestPage : System.Web.UI.Page
{

}

I ve tried adding IPostBackEventHandler to TestPage also, unfortunately no luck.

任何人能否帮助我,或者我是否对使用<条码>(MasterPage)无法做到这一点感到忽视?

Regards

P.S.,我知道(在我的测验中)我可以这样做:

public void RaisePostBackEvent(string eventArgument)
{
   Master_Pages_MainMasterPage myMaster = (Master_Pages_MainMasterPage)this.Master;

   myMaster.RaisePostBackEvent(eventArgument);
}

It s something I don t really want to do on each and every page that uses that MasterPage.

此外,我无视不同的点名,只是要回答问题。

最佳回答

令人高兴的是,我认为执行<条码>是一个非常好的想法。 IPostBackEventHandler 界面载于你的主页,因为RaisePostBackEvent几乎总是与网页上的控制或活动有关的特定网页。

System.Web.UI.Page 否则,“IPostBackEventHandler接口就不必在每一页上实施——已经到处。

页: 1 RaisePostBackEventmeth on this summary:

protected override void RaisePostBackEvent(IPostBackEventHandler source, string eventArgument)
{
    //call the RaisePostBack event 
    base.RaisePostBackEvent(source, eventArgument);

    if (source == SomeControl)
    {
        //do something
    }
}
问题回答

暂无回答




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

热门标签