473,386 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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 4177
RamananKalirajan
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

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

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

Similar topics

3
by: noViagraHere | last post by:
What do i need to add to the document line to stop getting an Unterminated String Constant error? itemtocheck = '1300'; document.writeln('<!--#include...
5
by: KathyB | last post by:
Hi, this is the first lines of a function. Although it runs, it still throws an "Unterminated string constant" error in the browser. It is all in one line, just wouldn't fit here. The error...
2
by: Daniel Secomb | last post by:
Hi, I'm using PostgreSQL 7.3.4 on phpPgAdmin 2.4.2 and I'm getting the following error when I try and run a SQL query on a script: Error -...
2
by: polilop | last post by:
When i open my page in IE it shows an error Unterminated string constant om Line..... When i look at the line it shows the line where the </SCRIPT> tag is ???? Moziila dose not see this error,...
5
by: ken s | last post by:
From server-side code I'm using Response.Write to display a javascript alert box. It works fine except when I try to include a new line character, which causes this javascript error: ...
7
by: vunet.us | last post by:
I have a function to open new window: function bla(){ newwin = window.open("page.asp?file=1&id=<%=ID %>","Image","other params") } This function works fine mostly, but sometimes, there is a...
7
basstradamus
by: basstradamus | last post by:
Hi When I am trying to eveluate object literal It causing Unterminated string constans error (firefox). var obiekt = (eval("("+data+")")); the data is carring object literal recived from server...
1
by: VUNETdotUS | last post by:
Let's say I have a string: div.innerHTML = "<a onclick='foo(\""+myWord+"\");'></a>"; in IE only (tested version 7) if var myWord = "English" then it works fine but if var myWord = "Modifier...
14
by: cptcanada | last post by:
I am trying to useSQL code inside VB code and I keep getting an Expected Case error on my first select statement, can any one help me with this?? Thanks ConnectionString =...
1
renji1981
by: renji1981 | last post by:
Hi pals Hers my link Primus Infotech Solutions - IT Services , Product Engineering , Web Based Applications Here Im getting a Unterminated String constant Error When you click on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.