I though all I would need to do is add this to the web.config so that it would validate to XHTML Strict
Code:
<xhtmlConformance mode="Strict" />
but when I tried to validate with the W3C validator I got the message that the page tentatively passed validation and that overridding needed to take place.
W3C validator told there was a Character Encoding Override in effect!
and
The detected character encoding "iso-8859-1" has been suppressed and "utf-8" used instead.
Is it possible to validate to XHTML strict using iso-8859-1?
Another thing is how do I get around the __viewstate that starts with the underscore? I know that ASP.NET 2.0 puts a div around it so that a block element holds the input (W3C validator is happy) but CSE Validator tells me that an underscore cannot start the value of an id or name attribute
Is there a work around for this and also when I take the server output from the view source and copy it to an html extension file, it validates. Is this a problem with the aspx extension?
I am not allowed to change the encoding.
Thanks in advance
bsw
Last edited by bsw2112; Mar 26th, 2007 at 05:25 PM.
Specifying iso-8859-1 in web.config worked.
I need to use iso-8859-1 so changing to utf-8 is not an option.
Now I am working on getting around the underscore in __viewstate
I am looking at this article (http://www.123aspx.com/redir.aspx?res=30966) that appears to provide a solution by making use of a literal control. Not sure what this is but will so find out
You need that viewstate hidden field for your ASP.NET controls on the page to work. But I did not know that this could be worked around as well, so that's a great link you've posted.
The problem is that I can't do anything manipulate the form and the postback and state retention isn't working. What am doing wrong?
I am a weak programmer especially with C# so perhaps this has something to do with my problems but for the time being I cannot get this to work in a .NET 2.0 environment
using System;
using System.IO;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
/// <summary>
/// Summary description for CustomPage
/// </summary>
namespace Liquid.Tutorial
{
public class CustomPage : Page
{
protected Literal inputViewState;
protected Literal outputText;
protected Label someLabel;
protected HtmlInputText dd;
protected Panel someDiv;
protected HtmlGenericControl someParagraph;
public CustomPage()
{
}
protected override Object LoadPageStateFromPersistenceMedium()
{
LosFormatter format = new LosFormatter();
String viewState = HttpContext.Current.Request.Form["__VIEWSTATE"].ToString();
return format.Deserialize(viewState);
}
protected override void SavePageStateToPersistenceMedium(Object viewState)
{
LosFormatter format = new LosFormatter();
StringWriter writer = new StringWriter();
format.Serialize(writer, viewState);
this.inputViewState.Text = "<input type=\"hidden\" name=\"VIEWSTATE\" value=\"" + writer.ToString() + "\"/>";
}
protected void Page_Load(Object sender, EventArgs e)
{
[b]//this does not work[/b]
Label someLabel = new Label();
someLabel.Text = "Text in a label";
//this does not work
HtmlGenericControl someParagraph = new HtmlGenericControl("p");
someParagraph.InnerText = "Paragraph text goes here";
Panel someDiv = new Panel();
someDiv.Controls.Add(someParagraph);
if (Page.IsPostBack)
{
//this does not work
//HtmlInputText dd= new HtmlInputText();
//outputText.Text = dd.Value;
//this does
outputText.Text = this.Request.Form.Get("dd");
}
}
}
public class CustomForm : HtmlForm
{
public CustomForm()
{
}
protected override void RenderAttributes(HtmlTextWriter output)
{
output.WriteAttribute("id", this.ID);
output.WriteAttribute("method", this.Method);
output.WriteAttribute("action", HttpContext.Current.Request.Path);
}
protected override void RenderChildren(HtmlTextWriter output)
{
foreach (Control c in base.Controls)
{
c.RenderControl(output);
}
}
}
}
I am trying to get information from that text field (dd) but cannot do it if I check for postback. (postback does not work for me)
The only way I get something back from dd is if I remove the postback condition and even then I can only get at it with
Code:
outputText.Text = this.Request.Form.Get("dd");
I tried this
Code:
HtmlInputText someTextBox = new HtmlInputText();
outputText.Text = someTextBox.Value;
but it didn't work
Other problems I am having is adding controls dynamically to the form:
Code:
HtmlGenericControl someParagraph = new HtmlGenericControl("p");
someParagraph.InnerText = "Paragraph text goes here";
Panel someDiv = new Panel();
someDiv.Controls.Add(someParagraph);
I also tried to add a textbox server control to the defaul.aspx page and it complained that it needs to be put in between <form runat="server"> (which I don't have)
Alright, I tried it out, but I never could get your sample to work. Then again I didn't spend a lot of time on this due to lack of it. Has this actually worked for you?
Alright, I tried it out, but I never could get your sample to work...
Not sure if you mean it doesn't run or it doesn't do what I said it's doing. The example runs. It just doesn't do what the guy's tut said. (his example is .net 1.1 and I am trying to make it work in .net 2.0 - perhaps this is why I am having problems...)
I am also adding a new zip with the modified code to see outputs better(the green and red output) although you never see the red as it depends on isPostBack that isn't working.
If you look at the source code you will notice that I modified the viewstate hidden input name and id from __viewstate to viewstate
bsw
Last edited by bsw2112; Mar 29th, 2007 at 11:50 AM.