[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to override the head title of aspx by ascx?

Posted on 2009-04-29
2
Medium Priority
?
704 Views
Last Modified: 2013-12-17
Hi

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>
</head>


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">
    <title>toy</title>
</head>

How can I do that?

I use asp.net and C#. Please provide code to illustrate

Thanks
0
Comment
Question by:techques
2 Comments
 
LVL 9

Accepted Solution

by:
tetorvik earned 75 total points
ID: 24267074
*.ascx.cs: use following

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

Assisted Solution

by:ppittle
ppittle earned 75 total points
ID: 24267080
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. : http://www.asp.net/learn/data-access/tutorial-03-vb.aspx

PJ
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Loops Section Overview
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

873 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