|
PageTitle.InnerText bug in Visual Studio.NET 2003 (Visual Studio) |
|
|
Written by: Evan Cummings
PageTitle.InnerText bug in Visual Studio.NET 2003One tricky bug in Visual Studio 2003 I ran across recently involved an exception being thrown when programmatically settting a page title by reading in a key from the web.config file. We first need to define our title as being run on the server side:
<title runat="server" id="PageTitle">
We can then set this value dynamically in the code-behind:
PageTitle.InnerText = ConfigurationSettings.AppSettings("title")
The exception in particular stated that a control being referenced does not exist, which is very strange - nothing is incorrect with the particular bit of code. I scratched my head at this for awhile. The html tag we defined was clearly set up to run at the server level, and our Page_Load() code is valid. The problem is that Visual Stuio.NET 2003 actually gets to helpful here and actually removes the runat="server" portion of our <title> tag. This is an intermittent issue, but it is something to keep in the back of your mind when working with the page through a configuration file!
|
|
|
|
|
|