PDA

View Full Version : [CLOSED] Unterminated string constant



t0ny
Aug 04, 2008, 9:52 AM
Hi there,

If I use an ext:textarea and populate it with some text from a database that has newlines in it, I get 'Unterminated string constant'.

'I think' this happens when coolite builds the page... I can see it falling over on this part:




this.SiteCommentsTextArea.setRawValue("blah blah blah

blah blah

blah blah blah

");

Timothy
Aug 04, 2008, 11:03 AM
What version of Coolite are you using? I had the same problem but they fixed it for me in SVN.

Cheers,
Timothy

Timothy
Aug 04, 2008, 11:05 AM
Link (http://forums.ext.net/showthread.php?threadid=931-16-1.aspx) to similar problem with double quotes; should now be encoded:

Cheers,
Timothy

geoffrey.mcgill
Aug 04, 2008, 11:50 AM
Hi t0ny,

As mentioned by Timothy, in the next version we've enquote'd the .Text value. Now characters like "\\n" and "\r" are automatically converted to "\\\\n" and "\\r".

EDIT: It looks like the current <ext:HtmlEditor> is also having problems escaping the "slash-n" newline character. I've tested the v0.6 release and everything appears to work properly.

You should be able to do a string.Replace on the string value coming from the database before setting the .Text property and replace instance of "\\n" and "\r" with "\\\\n" and "\\r".

Hope this helps.

geoffrey.mcgill
Aug 04, 2008, 12:58 PM
I forgot to post a sample I was testing with.

Example


<%@ Page Language="C#" %>

<%@ Register assembly="Coolite.Ext.Web" namespace="Coolite.Ext.Web" tagprefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
this.TextArea1.Text = @"blah blah blah
blah blah

blah blah blah
";
}

protected void Button1_Click(object sender, EventArgs e)
{
this.TextArea2.Text = this.TextArea1.Text;
}

protected void Button2_Click(object sender, EventArgs e)
{
this.Label1.Text = this.TextArea2.Text;
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>TextArea with newline characters</title>
</head>
<body>
<p><a href="NewLines.aspx">Reload</a></p>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" />
<p>
TextArea #1<br />
<ext:TextArea ID="TextArea1" runat="server" Height="150" Width="300" />
<ext:Button ID="Button1" runat="server" Text="Move" Icon="ArrowDown"
&#111;nclick="Button1_Click" />
</p>
<p>
TextArea #2<br />
<ext:TextArea ID="TextArea2" runat="server" Height="150" Width="300" />
<ext:Button ID="Button2" runat="server" Text="Submit" Icon="Printer"
&#111;nclick="Button2_Click" />

</p>
<asp:Label ID="Label1" runat="server" />
</form>
</body>
</html>


Hope this helps.

t0ny
Aug 06, 2008, 6:39 AM
Yep, that solved the problem. Working between two projects so only just got to look at this.
Do I need to be subscribed to the professional edition of Coolite to be able to use Toolkit 0.6 SVN?

If not is this still not recommended?

geoffrey.mcgill
Aug 06, 2008, 6:45 AM
Hi t0ny,

Thanks for the update. Glad to hear it's working for you now.

SVN access is available to all Professional Edition holders with a support subscription. more info (http://www.ext.net/store/). The SVN repository contains the absolutely most recent code (the stuff we're working on right now) and all version history.

designworxz
Feb 03, 2009, 9:42 PM
Hi geoffrey,

There's problem with Html Editor.
At page_load event am loading Html file to HtmlEditor.
When i Clear Htmleditor and Loads again on Button-Click event. "unterminated string Constant error comes"