Too many characters in character literal in javascript!!!

Hi All:

I have code:

string MyCust_Code = e.Row.Cells.FromKey("CusCode").ToString();

e.Row.Cells.FromKey("CusName").Value = "<span style='cursor:hand' onclick='javascript:PopupCampaign_Test('" + MyCust_Code + "');'><font color='#0000ff'>" + e.Row.Cells.FromKey("CusName").ToString() + "</font></span>";

And PopupCampaign_Test Javascript function:

function PopupCampaign_Test(stringrequest)

{

mywindow = window.open(
'../LGPopup/SearchCampaignReload.aspx?MyCus_Code='+stringrequest+'','','width=750,height=480,status=yes,scrollbars=no,resizable=no,menubar=no;toolbar=no,titlebar=no');

mywindow.moveTo(345, 120);

 

 

}

But this is Error: "Too many characters in character literal "

How Can change it to solve this problem???

THanks

0
duynnh
10/23/2007 10:31:04 AM
asp.net.client-side 24353 articles. 1 followers. Follow

9 Replies
1443 Views

Similar Articles

[PageSpeed] 10

You have quotes or a apostrophe in the literal text you are writing into your javascript. They need to be escaped or htmlencoded as entities.

For instance, &quot;
 

0
triggered
10/23/2007 2:46:55 PM

This looks like a duplicate post to this:

http://forums.asp.net/t/1173112.aspx

NC...

 

0
NC01
10/23/2007 2:56:53 PM

Hi NC01 !!!

Can you help me solve this problem with this codes.

Please help me!!!

Thanks & Regards

0
duynnh
10/23/2007 3:33:11 PM

Do this to HTML encode the customer code...

    string MyCust_Code = HttpUtility.HtmlEncode(e.Row.Cells.FromKey("CusCode").ToString());


You're <span> tag is also all screwed up becuase you didnt use quotes properly.  Change it to this (just copy and paste)...

    e.Row.Cells.FromKey("CusName").Value = "<span style=\"cursor:hand;\" onclick=\"PopupCampaign_Test('" + MyCust_Code + "');\"><font color=\"#0000ff\">" + e.Row.Cells.FromKey("CusName").ToString() + "</font></span>";


Hope this helps!  Please mark the helpful post(s) as Answer.

 


Josh Stodola ← Come check out my blog!
0
JoshStodola
10/23/2007 5:04:24 PM

string eventHandler = "JavaScript: PopupCampaign_Test('" + e.Row.Cells.FromKey("CusName").ToString() + "');";
string cellText = e.Row.Cells.FromKey("CusName").ToString();
int rowNumber = rowNumberOfFromKey_CusName_Row;

e.Row.Cells[rowNumber].Attributes.Add("onclick", eventHandler);
e.Row.Cells[rowNumber].Style.Add("cursor", "hand");
e.Row.Cells[rowNumber].Style.Add("color", "Blue");
e.Row.Cells[rowNumber].Style.Add("text-decoration", "underline");
e.Row.Cells[rowNumber].Text = cellText;

NC...

0
NC01
10/23/2007 5:06:15 PM

Hi Josh Stodola!!

Thanks for your support but With your codes In the first click the popup windows doesn't Focus(active) as parent windows but from the second click it's ok.

Please give me the solution, Thanks & regards

 

0
duynnh
10/24/2007 1:37:00 AM

In the javascript PopupCampaign function...

    mywindow = window.open('...');
   
mywindow.moveTo(345, 120);
    mywindow.focus();


Hope this helps!  Please mark the helpful post(s) as Answer.


Josh Stodola ← Come check out my blog!
0
JoshStodola
10/24/2007 3:49:00 AM

I gues u double posted,since i remember i replied to the same yesterday also.What u need to do is just check for quotes opening and close, or just need to escape the literal

 

 

www.codepal.co.nr


Cheers
Bino
www.codepal.co.in

Please Mark as Answer if you find the post useful.
0
binobose
10/24/2007 4:06:56 AM

Hi!

Thanks for your Supports. I tried but the same problem. Does anything else???

Thank & Regards

0
duynnh
10/24/2007 4:09:29 AM
Reply:

Similar Artilces:

Too many characters in character literal while calling javascript function.
Hi, I wanna call the java script function when a gridview's link is clicked.The link is dependent on the query string value of the row.I am using the the template column in the gridview as below code, <ItemTemplate>       <a style="color: Blue" href="javascript:gotoURL(this,<%#GetURl(DataBinder.Eval(Container.DataItem,'id'))%>);">               <%#GetMove(DataBinder.Eval(Container.DataItem,'M_Number').ToString())%> //This is the...

too many characters in character literal
I have this javascriptfunction kolla(hal) {  alert(document.getElementById('<%=txtHole'+hal+'Points.ClientID%>').value);     } the errormessage from VS2005 is too many characters in character literal   the functioncall is txtHole1Strokes.Attributes.Add("onchange", "kolla('1');");   how can i change the string?   also, this is ok document.getElementById('<%=txtHole8Strokes.ClientID%>').value;   // Regards Tomas  alert(document.getElementById('<%=txtHole %>'...

Error: Too many characters in character literal
Hi. I'm tryingout the CallBack Event handling code from here: http://www.asp.net/QuickStart/util/srcview.aspx?path=~/aspnet/samples/tipstricks/CallBackEventHandler.src   I'm using C#.   My problem is when I build the website I get error: "Too many characters in character literal" for line <asp:DropDownList ID="ParentDropDown" OnSelectedIndexChanged="GetChildren(this.options[this.selectedIndex].value, 'ddl')" Runat="server"> Please help. Thanks! You are missing ";" in  OnSelectedIndexChanged.. Try this. <asp:DropDownList ID="ParentDropDown" OnSe...

Why am I getting "Too many characters in character literal" here?
Why am I getting "Too many characters in character literal" here? <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> I checked another project that compiles, and the line above is exactly the same...?Clay Shannon,author of historical works, novels, and art/poetryhttp://www.knowitallsports.com/booklinks.aspx Are you sure that's the line causing the error?That error usually happens when you use single quotes when you should have used double quotes. Please Mark As Answer posts that ...

Error Message from HyperLink control : Too many characters in character literal
Hi all, I can getting this error message from the HyperLink control for some reason when using the following code:<asp:HyperLink     CssClass="text"     NavigateUrl="clients.aspx?CatType=<%# DataBinder.Eval(Container.DataItem, 'au_id')%>"     Text="<%# DataBinder.Eval(Container.DataItem, 'au_fname') %>"     Runat="server"     ID="HyperLink1" />Now I think the problem is because I am using single quotes and ASP.NET assuming its a Char (am I right here?), so if I replace these single quotes with double...

"Newline in constant" and "Too many characters in character literal" errors. Dataadapters and datatables.
I'm getting the above errors on line 41 (parameter delcaration)... been hitting my head on this for a while.. please help.  public static DataTable dtCleanVendorUsers(string username) {SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["VendorEvaluationConnectionString"].ConnectionString); SqlDataAdapter dataadapter = new SqlDataAdapter();dataadapter.SelectCommand = new SqlCommand("SELECT vendoruser_user_id, vendoruser_vendor_id, user_name, vendor_name, vendor_evaluated FROM vwVendorUsers WHERE (vendor_evaluated = 0) and (u...

too many characters in literal
thats my javascript error it wont build and this is my code <input type="hidden" runat="server" id="hdnAddInfoIndex" /> <asp:RadioButtonList ID="rblOffers" runat="server" AutoPostBack="false" OnSelectedIndexChanged="CheckAdditionalInfo('rblOffers')" > </asp:RadioButtonList>  function CheckAdditionalInfo(rbList) {var needAdditionalInfo = new Array(); var selectedValue = '';var radiobuttonlist = document.getElementById(rbList);needAdditionalInfo = document.getElementById("h...

superreview granted: [Bug 260660] RDFServ nspr logging for literals prints out a single character : [Attachment 159530] print more than a single character of the literal
Daniel Veditz <dveditz@cruzio.com> has granted timeless@myrealbox.com (working) <timeless@bemail.org>'s request for superreview: Bug 260660: RDFServ nspr logging for literals prints out a single character https://bugzilla.mozilla.org/show_bug.cgi?id=260660 Attachment 159530: print more than a single character of the literal https://bugzilla.mozilla.org/attachment.cgi?id=159530&action=edit ------- Additional Comments from Daniel Veditz <dveditz@cruzio.com> sr=dveditz ...

superreview requested: [Bug 260660] RDFServ nspr logging for literals prints out a single character : [Attachment 159530] print more than a single character of the literal
timeless@myrealbox.com (working) <timeless@bemail.org> has asked Daniel Veditz <dveditz@cruzio.com> for superreview: Bug 260660: RDFServ nspr logging for literals prints out a single character http://bugzilla.mozilla.org/show_bug.cgi?id=260660 Attachment 159530: print more than a single character of the literal http://bugzilla.mozilla.org/attachment.cgi?id=159530&action=edit ...

Foreign character client names are appearing as junk characters
Hi to all, We are using Oracle Database for an ASP.Net application.  In my Oracle database one record containing data as: njëmbëdhjetëæ!@#$%^&*()_ ãøàe-ré1ürkçå' but when I retrive that data to a log file it is showing : nj?mb?dhjet??!@#$%^&*()_ ???e-r?1?rk??' sk?ytene   Correct output:-njëmbëdhjetëæ!@#$%^&*()_ ãøàe-ré1ürkçå' skøytene MY Result: nj?mb?dhjet??!@#$%^&*()_ ???e-r?1?rk??' sk?ytene   Plz. help me to get the correct output..... Change the response enconding to UTF-8.You can change it in the web.config file in the globalizat...

.Net varible into client side JavaScript
I'm need to get a variable from my web app and place its value in a JavaScript. I tried doing this with a Label but I get the HTML included. I don't think I can use the <%# %> from classic ASP? Anyone have any ideas on how they would approach this problem? tbone_stl wrote:Anyone have any ideas on how they would approach this problem? Hi, and welcome to the ASP.NET forums. It's possible to pass a variable to a javascript function. I created a small coding snippet: <%@ Page Language="C#" %>   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http...

Client side encryption for Japanese Characters
In working on Client Side encryption in ASP.NET 2.0. I have used Javascript functions to implement RSA Encryption and I Decrypt the value at server side, it works fine for most of the Character but my main requirement is to implement it for the Japanese Characters. These Characters are two bit incoded and using the same algorithm gives my abnormal results .. Have any one tried working with Japanese characters. please do help out.. Thank you Santosh Hi Have you noticed the multilingual keywords in search engines like www.google.com which encode it like "%E3%81%AB&qu...

Romove character from string at client side
Hi friends, I have one text box with size of 100 characters. I don't want to allow the person to write "&" and "*" characters in text box at client side (Java Script). How can i do that operation without page postback? Please Reply soon. Thanks. If you're using AJAX, you can try with FilteredTextBox Extender: http://www.asp.net/AJAX/AjaxControlToolkit/Samples/FilteredTextBox/FilteredTextBox.aspx something like this can do it if you do not want to filter as they type. onblur="this.value=this.value.replace(/[\*&]/g);"  ...

WARNING! Some character(s) could not be converted into client's character set.
I received this message when it was executing the command SELECT. Which is the reason? Paulo wrote: > I received this message when it was executing the command > SELECT. Which is the reason? Ignore it ... that simlpy means some characters that are in the result set cannot be displayed on your terminal ( e.g. Unicode characters that are beyond your terminal's capability ). ...

Web resources about - Too many characters in character literal in javascript!!! - asp.net.client-side

JavaScript Kit- Your comprehensive JavaScript, DHTML, CSS, and Ajax stop
Your comprehensive JavaScript, DHTML, CSS, and Ajax stop

Let's Code: Test-Driven Javascript by James Shore — Kickstarter
James Shore is raising funds for Let's Code: Test-Driven Javascript on Kickstarter! A screencast series focusing on rigorous, professional Javascript ...

Eloquent JavaScript: A Modern Introduction to Programming
... and pragmatics. I loved the tutorial-style game-like program development. This book rekindled my earliest joys of programming. Plus, JavaScript! ...

Lightbox (JavaScript) - Wikipedia, the free encyclopedia
On a Lightbox-enabled page, a user can click an image to have it magnified in a Lightbox window, which resizes itself according to the size of ...

Open Directory - Computers: Programming: Languages: JavaScript: Tools: Obfuscators
about dmoz - help Top : Computers : Programming : Languages : JavaScript : Tools : Obfuscators Tools for obfuscation/compression JavaScript code. ...

Facebook File-Transfer App Pipe Relaunches, Now Works Via JavaScript, WebRTC
... allowed Facebook users to send and receive files up to 1 gigabit in size. A new version of Pipe debuted Monday, and the app now works via JavaScript ...

Under the Hood: The JavaScript SDK - The use of polyfills - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Under the Hood: The JavaScript SDK - The use of polyfills geschrieben. Du kannst den vollständigen ...

JavaScript SDK - Facebook-Entwickler
Overview The JavaScript SDK provides a rich set of client-side functionality for accessing Facebook...

Senior Front-End Developer (Javascript and AJAX)
Company: Sometrics Category: Software Development Location: Los Angeles, CA How to Apply: jobs@sometrics.com Description: We are looking for ...

Badass JavaScript (@badass_js) on Twitter
WebGLWorker is an open source library that allows using WebGL from Web Workers. Great work as always from @kripken . blog.mozilla.org/research/2014/… ...

Resources last updated: 12/27/2015 6:37:37 PM