problem with render

Results 1 to 2 of 2

Thread: problem with render

  1. #1
    Join Date
    Dec 1969

    Default problem with render

    I&#039;m building an application and it&#039;s almost complete. Now I need to register it with search engine. <BR> <BR>For SEO (search engine optimisation) reason it is required to move the viewstate hidden input to the bottom of the page.<BR> <BR> I used following code (got it from dotnetnuke):<BR>---------------------------------------------------------------------------------------------------<BR>&#039; This method overrides the Render() method for the page and moves the ViewState <BR>&#039; from its default location at the top of the page to the bottom of the page. This <BR>&#039; results in better search engine spidering. <BR>&#039; <BR>Protected Overrides Sub Render(ByVal writer As System.Web.UI.HtmlTextWriter) <BR>Dim stringWriter As System.IO.StringWriter = New System.IO.StringWriter <BR>Dim htmlWriter As HtmlTextWriter = New HtmlTextWriter(stringWriter) <BR>MyBase.Render(htmlWriter) <BR>Dim html As String = stringWriter.ToString() <BR>Dim StartPoint As Integer = html.IndexOf("&#060;input type=""hidden"" name=""__VIEWSTATE""") <BR>If StartPoint &#062;= 0 Then &#039;does __VIEWSTATE exist? <BR>Dim EndPoint As Integer = html.IndexOf("/&#062;", StartPoint) + 2 <BR>Dim ViewStateInput As String = html.Substring(StartPoint, EndPoint - StartPoint) <BR>html = html.Remove(StartPoint, EndPoint - StartPoint) <BR>Dim FormEndStart As Integer = html.IndexOf("&#060;/form&#062;") - 1 <BR>If FormEndStart &#062;= 0 Then <BR>html = html.Insert(FormEndStart, ViewStateInput) <BR>End If <BR>End If <BR>writer.Write(html) <BR>End Sub <BR>-----------------------------------------------------------------------------------<BR>It&#039;s working absolutely fine. The main purpose is solved. <BR>But one new problem started after implementing it, as following:<BR> <BR>in the code behind some variable and functions have been used (printing output of one function) e.g. <BR> <BR> &#060;HEAD id="Head"&#062;<BR> &#060;TITLE&#062;<BR> &#060;%Title() %&#062;<BR> &#060;/TITLE&#062;<BR> <BR>And the Render method is disturbing the output/formatting of these server side executions. It is breaking the ourput and placing it on the top of the page.<BR> <BR>If the functions/variables are called like this (printing one variable):-<BR>&#060;HEAD id="Head"&#062;<BR> &#060;TITLE&#062;<BR> &#060;%=Title %&#062;<BR> &#060;/TITLE&#062;<BR> <BR>Then this is not disturbing the out put in this tag.<BR> <BR>can any one tell me what is the difference between these?<BR> <BR>Is there any other way for implementing the Render method?<BR> <BR>Or I have to change the serverside (code behinds) implementation (definitely I&#039;ll be in soup)?<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: problem with render

    Didn&#039;t you say that one of the methods worked? If so, why not just use it? If neither worked, then maybe explain a bit more about what you&#039;re doing and what the problem is?<BR><BR>BTW...I think that bit about viewstate at the top being bad for SEO is a complete crock. Somebody with an over-active imagination thought that one up.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts