November 12, 201015 yr When using the w3c validation tool I'm getting an error telling me that I "can't use input here" I know it refers to not being allowed to use the tag directly inside a form, but if you look at my source code: http://siegemachine.net you'll see the input is automatically nested in div tags by asp. What's the problem? Cheers
November 12, 201015 yr It's probably the first backslashe in the input value fields, HTML is trying to interpret those as element closing tags. The solution is not to use values with backslash as the first characte, or try a less strict Doctype. Edited November 12, 201015 yr by BlueDreamer
November 12, 201015 yr Author The problem is I can't change the input lines, they get automatically created by the server. It's not a big deal I suppose, but I'm creating this as part of an assignment for my degree and want valid markup. I could change the doctype but I decided on strict to force myself to meet a high standard, as I've not really made a decent website before.
November 13, 201015 yr Author For anyone who is interested, this code solves the problem by removing the fields protected override void Render(HtmlTextWriter output) { // instance of string builder System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); // instance of string writer System.IO.StringWriter stringWriter = new System.IO.StringWriter(stringBuilder); // to write the new html... HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter); // loop through each control in this document foreach (Control ctrl in this.Controls) ctrl.RenderControl(htmlWriter); String html = stringBuilder.Replace("/>", "/>").ToString(); // find those pesky hidden fields int intViewStart = html.IndexOf("<input type=\"hidden\" name=\"__VIEWSTATE\""); // find the end of the hidden field int intViewFinish = html.IndexOf(">", intViewStart) + 1; // pinpoint where they fields are and cut them out string strViewTag = html.Substring(intViewStart, intViewFinish - intViewStart); System.Diagnostics.Debug.WriteLine(strViewTag); html = html.Replace(strViewTag, ""); // write new string to file output.Write(html); } }
Create an account or sign in to comment