how can i move the viewstate hidden field in asp.net??
Discuss how can i move the viewstate hidden field in asp.net?? in the Search Engine Optimization forum on SEO Chat. how can i move the viewstate hidden field in asp.net?? Search Engine Optimization forum discussing general tips and tricks to optimize your website for the search engines as a white hat or black hat. Find ideas to fine tune your website for top rankings using keywords, meta tags, SEF, and more.
Our weekly Search Engine newsletter covers the constantly evolving world of search engine optimization like no one else. To stay abreast of all the latestest news, reviews, and how-to's, subscribe today!
BuySellLinks.com is a Text Link Advertising Brokerage by the founder of LinkAdage that specializes in high end quality text links and a controlled membership base. To quickly build inventory we are paying webmasters who add quality domains that we can accepted into our inventory. We also offer free installation.
Tired of dealing with shady text link buyers and/or sellers? Try BuySellLinks.
This month's featured article takes a peek at Google Adsense and teaches you everything you need to know to properly maintain your account and get the most bang for your buck.
Posts: 5
Time spent in forums: < 1 sec
Reputation Power: 0
how can i move the viewstate hidden field in asp.net??
hello,
i am optimizing www.ilanguage.com/en for search engines, directories & crawlers.
i was wondering if there is a way to move the viewstate hidden field in asp.net (<input type="hidden" name="__VIEWSTATE" value="dDwtMzU.........) towards the bottom of the page, so that the body text of the page comes before the viewstate field, at least for the home page??
the reason i am doing this is because with the viewstate field before the body text of the website it greatly limits the ability for the website to rank well, since the body text is where alot of SE's look for the keywords, and the viewstate field is so long.
Posts: 25
Time spent in forums: 21 h 15 m 22 sec
Reputation Power: 0
Move Viewstate in ASP.NET
This code will move the viewstate to the bottom of the rendered HTML. The best bet would be to throw this into a base page class that all of the pages in your project inherit from. Otherwise, you can just throw this code onto every page that requires moving the viewstate. Also, be sure to disable viewstate (EnableViewState="False") on any controls that don't actually need it. By default, it is turned on for every control on a page.
protected void Render(System.Web.UI.HtmlTextWriter writer) {
System.IO.StringWriter stringWriter = new System.IO.StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
base.Render(htmlWriter);
string html = stringWriter.ToString();
int StartPoint = html.Indexof("<input type="hidden" name="__viewstate"");
if (StartPoint >= 0) {
int EndPoint = html.Indexof("/>", StartPoint) + 2;
string viewstateInput = html.Substring(StartPoint, EndPoint - StartPoint);
html = html.Remove(StartPoint, EndPoint - StartPoint);
int FormEndStart = html.Indexof("</form>") - 1;
if (FormEndStart >= 0) {
html = html.Insert(FormEndStart, viewstateInput);
}
}
writer.Write(html);
}
Quote:
Originally Posted by alex_1®
hello,
i am optimizing www.ilanguage.com/en for search engines, directories & crawlers.
i was wondering if there is a way to move the viewstate hidden field in asp.net (<input type="hidden" name="__VIEWSTATE" value="dDwtMzU.........) towards the bottom of the page, so that the body text of the page comes before the viewstate field, at least for the home page??
the reason i am doing this is because with the viewstate field before the body text of the website it greatly limits the ability for the website to rank well, since the body text is where alot of SE's look for the keywords, and the viewstate field is so long.