开发者

Display content from Database (While loop) in C# / .NET

I'm very new to .NET and unfortunately having to take over an ex-colleague's project.

Part of my code has a while loop to loop out query results...

        while (reader.Read())
        {
            pageTitle.Text = reader["title"].ToString();
        }

I am currently using this to retrieve the Page Title from a Table in my Database.

I want to display this in my <title></title> of the SiteMaster file, but unfortunately righ开发者_运维技巧t now using this method:

<title><asp:Label ID="pageTitle" runat="server" /></title> is giving me a span tag inside the <title>. I want to remove the altogether and just have the Title value.

Can anyone explain the best way to do this?

Appreciate your help and patience with this.

Thank you


Make sure the <head> tag has the runat="server" attribute, for example:

<head runat="server">

Then set the title by using:

Page.Title = reader["title"].ToString();


Use the <asp:Literal> tag instead.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜