473,216 Members | 1,254 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,216 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 4163
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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.