开发者

how to set title within content page asp.net

开发者 https://www.devze.com 2022-12-26 11:22 出处:网络
I have created a Content Page using Master Page. Within Master Page, I have created the following tag for Title:

I have created a Content Page using Master Page.

Within Master Page, I have created the following tag for Title:

<head id="Head1" runat="server">
    <title></title>   
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />   
</head>

Within Content Page, following are set:

   protected void Page_Load(object sender, EventArgs e)
{

    if (!Page.IsPostBack)
    {
        if (String.IsNullOrEmpty(Request.QueryString["PatientRegistrationKey"]))
        {
           // ....
        }
        else
        {
            this.Page.Title = "My New Title";
            //....
        }
    }

Though I am also setting the Master Page at run time as bellow:

 protected void Page_PreInit(Object sender, EventArgs e)
    {
        if (String.IsNullOrEmpty(Request.QueryString["PatientRegistrationKey"]))
            this.MasterPageFile = "~/MasterPages/A.master";
        else
            this.MasterPageFile = "~/MasterPages/B.master";
    }

开发者_开发百科While getting open this page in browser, I got following Title:

http://localhost:3562/?PatientRegistrationKey=0 - My New Title

Please advice for the changes, so that there should be only My New Title within title, nothing extra like query string etc.

Any help would be appreciated.


If you don't set a default title on the page, the page will show the URL as the title. Go set the page title in the .aspx file:

<%@ Page Language="C#" MasterPageFile="..."
    AutoEventWireup="true" Title="My Default Title" %>
0

精彩评论

暂无评论...
验证码 换一张
取 消