IntroductionSometimes a client wants that the same text show in the title bar of every page for the entire website, not the variety of text on every page. You can do this in one of 2 ways.
Note: To do so in both cases you need to use a common page, either a Master Page or a Web User Control.To learn more about this, check the following procedure.Add a new "Website" named "Website1".As I have said you earlier, you can do this in one of 2 ways. So here is both ways.
Here Key is the "Title" and its value is "MY Website Title".Now you can access this key in a common file such as a master page and any user control file like header or footer.Matser Page: Add a Master page named "Masterpage.master" to the website.And now add the following code on page_Load event in the .cs file of the Master Page.
Here the "Title" name should be the same as what you created in the Web.Config file.Now add the Web Form named "MyPage.aspx" to the website as in the following:And select the master page as in the following:Now add some text onto the page only for identification and run it.Web User Control: Add a Web User Control named "MyControl.acsx" to the website.And now add the following code for the page_Load event in the .cs file of the Web User Control.
Here the "Title" name should be the same as what you created in the Web.Config file.Add a Web Form named "Default.aspx" to the website without adding a master page.Add the "MyControl.acsx" to the "Default.aspx" page as in the following:Now run the page.Through Client Side using JavaScripts
This way is client-side because JavaScript is used to set the title of the page. There is no need to change the Web.Config file. It is a very simple way compared to the first way.Just write the single line of the following code in the <Script> tag:document.title = " MY Website Title";Now you can write this code in a common file, it can be a master page and any user control file like header or footer.Matser Page: Add a Master page named "Masterpage.master" to the website.And now add the following code in the <script> tag in the <head> tag of the "MatserPage.master".
Now add the web form named "MyPage.aspx" to the website.And select the master page.Now add some text on page only for identification and run it.Web User Control: Add a Web User Control named "MyControl.acsx" to the website.And now add the following code to the <script> tag in the <body> tag of "MyControl .acsx".
Add a Web Form named "Default.aspx" to the website without adding a master page.Add the "MyControl.acsx" to the "Default.aspx" page.Watch this script here:Now run the page.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: