User events do not fire in Httphandler

Uitest.ascx usercontrol events do not fire, does anyone know about this?

        business.Pages.Page page1 = new business.Pages.Page();            

        System.Web.UI.HtmlControls.HtmlForm form = 
              new System.Web.UI.HtmlControls.HtmlForm();
        UserControl uc = 
              (UserControl)page1.LoadControl("~/usercontrols/uitest.ascx");            

        form.Controls.Add(uc);

        page1.Controls.Add(form);

        StringBuilder sb = new StringBuilder();
        StringWriter tw = new StringWriter(sb);
        HtmlTextWriter hw = new HtmlTextWriter(tw);

        page1.RenderControl(hw);            

        context.Response.Write(newContent);
+3
source share
2 answers

Let me go through what happened here. You created an instance business.Pages.Page, which means that the page class constructor is being called. Then you added the control to the collection Controls. Then you called the method RenderControl()on this page.

. OnInit, OnLoad .., - , ? HttpHandler, , , , , .

System.Web.UI.Page.ProcessRequest(), , , , .

, - , . new() , . RenderControl(), . , !

+2

HttpHandler ( ), .

- , ASP.Net. IHttpHandler. ProcessRequest() Page Fire - FrameworkInitialize(), Init()... OnLoadComplete(), OnSaveStateComplete().

, , .

+1

Source: https://habr.com/ru/post/1718139/


All Articles