Posted by zoftworx 2 years 4 weeks ago
Hi,
I am busy trying to build a mobile web site with ASP.NET, but I am having a difficult time to remove all the errors when I test it on ready.mobi. It seem that I somehow need to completely disable viewstate, but even by doing so, does not really do it completely .
At the moment I just have a very simple web site with one master.page and one content page (default.aspx). For both the master.page and default.aspx pages I have put (inside page_load):
Page.EnableViewState = false;
But when I run my site through http://ready.mobi, then it creates a failure for not having valid markup. It seem to me that the main reason for this, is that if you have a element, then only specific content elements. The only allowed content elements are:
The content of element type "form" must match "(h1|h2|h3|h4|h5|h6|ul|ol|dl|p|div|pre|blockquote|address|hr|table|script|noscript|fieldset)+".
Even with all the viewstates disabled, I still get the following in my HTML for the page:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.2//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile12.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> </title> </head> <body> <form method="post" action="/default.aspx" id="aspnetForm"> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE1MjQ5ODA0NjlkZKVUdXajOAHB0AuXphqwCVhfazGq" /> <div> <span id="ctl00_ContentPlaceHolder1_Label1"> this is a test </span> <input type="submit" id="btnSubmit" class="hidden" /> </div> </form> </body> </html>
If you look at the HTML above, then you will see that ASP.NET still includes a VIEWSTATE inside a "hidden" element.
How do I prevent to get ANY viewstate included? Or alternatively, not getting the
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTE1MjQ5ODA0NjlkZKVUdXajOAHB0AuXphqwCVhfazGq" />
directly after the "form" tag, so that it will comply?
I am using MVS 2008 standard, C# and ASP.NET 3.5.
If anyone experienced the same problem and found a solution, then I will really appreciate any/all advice.
Thanks in advance!
Best Regards
Jan




Sign in or register to reply.