page_load another handler?

Posted by joe doe on Stack Overflow See other posts from Stack Overflow or by joe doe
Published on 2010-06-09T11:28:01Z Indexed on 2010/06/09 11:32 UTC
Read the original article Hit count: 166

Filed under:

can someone please explain why this code is not working as expected:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class temp : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write("foo<br>");
        this.Load += new EventHandler(temp_Load);

    }

    void temp_Load(object sender, EventArgs e)
    {
        Response.Write("bar<br>");
        Response.End();
    }
}

trying to add another handler for page Load event so that output would be:

foo<br>
bar<br>

© Stack Overflow or respective owner

Related posts about ASP.NET