tags:

views:

484

answers:

2

Hi,

Am a newbie to asp.net I've an asp.net page which uses a user control. On Page_Load event of this control,I want to change the title of parent aspx page. Need help on this please.

+2  A: 

You can try create a property in usercontrol and next call this property using your instance of usercontrol in page like

In UserControl

    protected void Page_Load(object sender, EventArgs e)
    {
        this.MyProperty = "This is a test";
    }

    public string MyProperty { get; set; }

` In Page

    protected void Page_Load(object sender, EventArgs e)
    {
        WebUserControl11.PreRender += new EventHandler(WebUserControl11_PreRender);
    }

    void WebUserControl11_PreRender(object sender, EventArgs e)
    {
        string str = WebUserControl11.MyProperty;
        this.Header.Title = str;
    }
pho3nix
Just a hair complicated, don't you think? :)
Hugoware
Maybe yes, but remember this guy need get text from a property in usercontrol, maybe another solution work, but this is my solution.
pho3nix
This works for me!Thanks a ton pho3nix!u rock!
+4  A: 
protected void Page_Load(object sender, EventArgs e)
{
    Page.Title = "New Title";
}
Chris Mullins