c# - Page.Title vs Title tag in asp.net -


i using asp.net. have noticed can configure page title (static , dynamic both) in 2 ways:

  1. we have title attribute in page directive:

      <%@ page language="c#" inherits="_default"  title="my title" ......%> 
  2. we have <title>tag in page:

    <title runat="server" id="mytitle"> title</title> 

both can accessed in code-behind file:

    mytitle.text = "title code behind";     page.title = "page title cs"; 

and have found page directive overrides html title. 1 should use , why ?

the biggest difference mytitle.text have decorate title element id , runat attributes, , remember it's name can reference it. accessing value isn't easy child pages when you're using masterpage instance..

on other hand, page.title common every page, it's more universal in opinion. every new developer you'll work won't have learn new, use page.title format..

so vote go "traditional" page.title

whichever use, stick it, won't mix various ways of setting title. way won't have worry event happens first or colleague overwriting values.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -