469,322 Members | 1,652 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,322 developers. It's quick & easy.

Unterminated string constant-javascript

hemantbasva
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
Bangalore
Oct 20 '08 #1
3 3840
RamananKalirajan
607 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

Regards
Ramanan Kalirajan
Oct 20 '08 #2
iam_clint
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
  4.  
... 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');");  
  2.  
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'
  4.  
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.