Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cannot add to the head control
Message
From
06/10/2008 03:50:15
 
 
To
05/10/2008 16:34:46
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01352874
Message ID:
01352922
Views:
30
This message has been marked as the solution to the initial question of the thread.
Hi,

Don't replace the existing Head element content - work with it. e.g
HtmlGenericControl hgc1 = new HtmlGenericControl("BASE");
hgc1.Attributes.Add("HREF",  oProcess.oApp.cHttp );
loHead.Controls.Add(hgc1);
(C# but you get the idea). Make the default Title element runat server and access it directly.
HTH,
Viv

>I have this GetHeader() method which is called for every page and it inserts the proper header in the head control:
>
>
>    Public Function GetHeader() As String
>        Dim lcHeaderHttps As String = ""
>        Dim loHead As System.Web.UI.HtmlControls.HtmlGenericControl = New System.Web.UI.HtmlControls.HtmlGenericControl()
>        Dim loStringBuilder As StringBuilder = New StringBuilder()
>
>        ' If we are under Https
>        If lHeaderHttps Then
>            lcHeaderHttps = oProcess.oApp.cHttps
>        End If
>
>        ' Put the BASE HREF in the head
>        loHead = oProcess.oPage.FindControl("Head")
>
>        loHead.InnerHtml = "<TITLE>" + oProcess.oApp.cTitle + "</TITLE>" + _
>         "<BASE HREF=" + oProcess.oApp.cHttp + ">" + _
>         "<link rel=""STYLESHEET"" href=""StyleSheet.css"" type=""text/css"">"
>
>        ' If we want the header
>        If lHeader Then
>            loStringBuilder.Append("<A HREF=http://localhost/optic/Administration.aspx>Administration</A>")
>            loStringBuilder.Append("<P>")
>        End If
>
>        Return loStringBuilder.ToString
>    End Function
>
>
>But, this is ok for as long as I do not have anything the head control already. But, in one specific page, we need to have some custom code in the head control. So, basically, this method will do its work but should also take in consideration to add the actual custom code of the head control. So, basically, on the loHead.InnerHtml line, I could simple replace the = sign with +=. But, when doing it, I have:
>
>"Cannot get inner content of Head because the contents are not literal."
>
>So, basically, I can initialize it but I cannot add to it.
>
>Anyone would know what I should do?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform