How to override the head title of aspx by ascx?

Posted on 2009-04-29
Last Modified: 2013-12-17

I have a aspx page which includes 2 placeholder:
top.ascx and main.ascx

In top.ascx, it has

<head runat="server">
    <title>Welcome to my website</title>

In main.ascx, it has a drop down menu to let user choose the product name.

When a user select a product name from drop down list in main.ascx, e.g. toy, then the title in head of top.ascx would change to

<head runat="server">

How can I do that?

I use and C#. Please provide code to illustrate

Question by:techques
    LVL 9

    Accepted Solution

    *.ascx.cs: use following

    this.Page.Title = "new title";
    LVL 8

    Assisted Solution

    In the code behind of main.ascx (main.ascx.cs), implement an event handler for the DropDownLists SelectionChanged Event:

    public class main : System.Web.UI.UserControl
    protected void DropDownList1_SelectionChanged(object sender, EventArgs e)
    this.Page.Title = "";  //Change Title based on DropDownList1, ie DropDownList1.SelectedText

    Note:  I find it odd that you're using a UserControl to control the Title of a Page.  I would think you'd be better off using Master Pages.  Take a look at Scott Mitchel's tutorial on MasterPages if you're unfimiliar with the concept of them. :


    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now