Dear JS-Support,
We do not know it is a bug or not, but annoying:
in SetHtmlRepresentation(this, string htmlRepresentation) the string htmlRepresentation doesn't tolerate spaces or control characters.
spaces or control characters (like new line): exception in Simulator:
"DESCRIPTION: Uncaught SyntaxError: Unexpected token ILLEGAL"
Other control characters: exception at Browser.
e.g.
working -without exception:
string html = @"<table id=""table_id"" class=""display""><thead><tr><th>Firstname</th><th>Lastname</th><th>Age</th></thead><tbody></tr><tr><td>Jill</td><td>Smith</td><td>50</td></tr><tr><td>Eve</td><td>Péter</td><td>94</td></tr></tbody></table>";
NOT working -exception:
string html = @"
<table id="table_id" class="display">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 Data 1</td>
<td>Row 1 Data 2</td>
</tr>
<tr>
<td>Row 2 Data 1</td>
<td>Row 2 Data 2</td>
</tr>
</tbody>
</table>";
CSharpXamlForHtml5.DomManagement.SetHtmlRepresentation(this, html);
(Note: the above code is a sample only (using <thead> and <tbody> tags from a 3rd party js lib -but it is not relevant concerning the topic)
What we recommend to you:
-It's should be better to source code formatting & readability to allow formatted string htmlRepresentation,
-you should remove the control characters automatically immediately before build process.
e.g.:
public static string RemoveControlCharacters(string inString)
{
if (inString == null) return null;
StringBuilder newString = new StringBuilder();
char ch;
for (int i = 0; i < inString.Length; i++)
{
ch = inString[i];
if (!char.IsControl(ch))
{
newString.Append(ch);
}
}
return newString.ToString();
}
What do you think ?
We share it as we hope to help others.
Waiting for your kind reply,
Best Regards,
Péter