471,887 Members | 1,292 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,887 software developers and data experts.

Unterminated string constant-javascript

i have written a the following javascript code to copy data onto clipboard but i am getting error
Unterminated string constant

code in cs file

Expand|Select|Wrap|Line Numbers
  1. if (lblProcedureID != null)
  2.                     {
  3.                         lnkHold.Attributes.Add("onclick", "javascript:copyText('Procedure Id-" + lblProcedureID.Text + " Proceudre Title-" + ProcedureTitle.Text + " Procedure Description-" + ProcedureDesc.Value + "');"); 
  4.                         //lnkHold.Attributes.Add("onclick", "javascript:copyText('" + (ProcedureDesc.Value).ToString() + "');");

javascript in aspx file

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" language="javascript">
  2.             function copyText(copyDivText) 
  3.             {
  4.                 //var copyDivText = document.getElementById('labelclipboard').value;
  5.                 window.clipboardData.clearData();
  6.                 var returnVal = window.clipboardData.setData('Text', copyDivText); 
  7.                 alert("Procedure details copied"); 
  8.             }
  9.     </script>
sometimes i am also getting error
") expected"

please help as its a urgent requirement

Hemant Basvapattan
Oct 20 '08 #1
3 3990
608 512MB
Sorry I dont know much things about CS but ur code is working well in HTML (that I tried). The problem may be in ur code is in this line

[HTML]lnkHold.Attributes.Add("onclick", "javascript:copyText('Procedure Id-" + lblProcedureID.Text + [/HTML]

Before the Procedure Id- there was a single quotes but it was not ended. Just check it out

Ramanan Kalirajan
Oct 20 '08 #2
1,208 Expert 1GB
In your c# you are passing these 3 items into your string
Expand|Select|Wrap|Line Numbers
  1. lblProcedureID.Text
  2. ProcedureTitle.Text
  3. ProcedureDesc.Value
... as far as I can tell you aren't validating these items so let me put this in context..

lets say lblProcedureID = 13, ProcedureTitle = "bob's palace", ProecureDesc = "this is something"

Expand|Select|Wrap|Line Numbers
  1. lnkHold.Attributes.Add("onclick", "javascript:copyText('Procedure Id-13 Proceudre Title-bob's palace Procedure Description-this is something');");  
now lets see the problem
Expand|Select|Wrap|Line Numbers
  1. Javascript interprets
  2. String1: 'Procedure Id-13 Procedure Title-bob'
  3. Unterminated String: s palace Procedure Description-this is something'
as you can see the string starts and ends before everything is executed.

This is how I imagine you are coming up with this error.
Oct 20 '08 #3
yes the problem is with the procedure description only.either due to length or due to special character. i will trace it out
Thanks everyone for help
Oct 21 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by noViagraHere | last post: by
2 posts views Thread by Daniel Secomb | last post: by
2 posts views Thread by polilop | last post: by
5 posts views Thread by ken s | last post: by
7 posts views Thread by vunet.us | last post: by
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.