too many characters in character literal

I have this javascript

function kolla(hal)







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



// Regards Tomas

7/25/2007 7:32:11 AM 93655 articles. 5 followers. Follow

7 Replies

Similar Articles

[PageSpeed] 31

 alert(document.getElementById('<%=txtHole %>' + hal + '<%=Points.ClientID%>').value);

Regards Mike
My site
7/25/2007 8:25:24 AM

Ok thx but then I get error:

"the name txtHole does not exist in the current context" and "the name Points does not exist in the current context"



7/25/2007 11:15:41 AM


Ok thx but then I get error:

"the name txtHole does not exist in the current context" and "the name Points does not exist in the current context"


That rather begs the question what you thought this: getElementById('<%=txtHole'+hal+'Points.ClientID%>') represents. How were you trying to apply a value? Where do the parts come from?  What would the client-side id of the element look like?  Would it be eg txtHole8Points?  If so, try this:

getElementById('txtHole' + hal + 'Points') 

Regards Mike
My site
7/25/2007 11:45:20 AM

Ok, what I want is this.

I have 9 textboxcontrols + 1 textboxcontrol wich is sum.

what I want is to enter values in each textbox and when I leave that textbox I want the sum calculated in sum-textbox. I have tried the the textchanged-event but that required autopostback to work and I dont want that.

Instead I have a javascript that I want to calculate the asp-textboxes. How can I reach a asp textbox value from javascript? I want a javascript function that takes a parameter, hole-number som I can determine which textbox called it.

7/25/2007 8:33:25 PM

<asp:TextBox ID="txtFirst" runat="server" onblur="javascript:CalculateSum(this)" />

<asp:TextBox ID="txtSecond" runat="server" onblur="javascript:CalculateSum(this)" />

<asp:TextBox ID="txtSum"  runat="server"  />


function CalculateSum(txtCntrl)

      // if you wanted to know which control triggerd the event

       var strTextBoxThatCalled = txtCntrl.Id;

       var strTextBoxValue = txtCntrl.value;

       var strVal = document.getElementById('<%= txtSum.ClientID =>').value;



            strVal.value = parseInt(strVal) + parseInt(strTextBoxValue);

      catch(e) { }


 There you go. I would not use try catch though, I personally dont thing that is good programming. I jsut put that there so you know to validate whether or not they are integer values using IsNaN.

Best Regards

7/25/2007 10:17:24 PM
ok thx! that would do the trick!
7/25/2007 10:47:18 PM

If you were thanking me, your welcome. Please remember to mark the answer


Best Regards,   Good Luck! 

7/25/2007 10:49:42 PM

Similar Artilces:

Error: Too many characters in character literal
Hi. I'm tryingout the CallBack Event handling code from here:   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...

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 ='../LGPopup/SearchCampaignReload.aspx?MyCus_Code='+strin...

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...

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/poetry 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...

Funny character being added instead of spaces in .net web forms...please help
Hi,in all of my pages I have the following html code:&nbsp;&lt;TD class=padding colSpan=2 height=23&gt;&lt;div align="center"&gt;&lt;A &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; href="#"&gt;Privacy Policy&lt;/A&gt; »&lt;a href="#"&gt; Terms of Use&lt;/a&gt;&lt;/div&gt;&lt;/TD&gt;on my default.aspx page, this gets displayed as: Privacy Policy » Terms of Useand the code isPrivacy Policy » Terms of UseCan ...

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 requested: [Bug 260660] RDFServ nspr logging for literals prints out a single character : [Attachment 159530] print more than a single character of the literal (working) <> has asked Daniel Veditz <> for superreview: Bug 260660: RDFServ nspr logging for literals prints out a single character Attachment 159530: print more than a single character of the literal ...

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 <> has granted (working) <>'s request for superreview: Bug 260660: RDFServ nspr logging for literals prints out a single character Attachment 159530: print more than a single character of the literal ------- Additional Comments from Daniel Veditz <> sr=dveditz ...

Foreign Characters not Dsiplaying in Web Form
Hello All, Hoping someone can help.  I have a web form with a textbox that is being populated from an nvarchar output parameter in SQL Server.  The foreign characters show up fine in the db table and in the results of the stored procedure but some of the characters with special accent marks show up as boxes. I've been searching for a solution for a while and have tried several suggestions including putting the following in the web.config file.  <globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US" uiCulture="en-US"/> I'v...

Unreadable characters at top of web form
Has anyone experienced this in their ASP.NET 2.0 applications?  I am using VB.NET, and a little AJAX (1 or 2 UpdatePanels only) and/or an Accordion control with at most 9 panes.  It is hard to describe the problem.  I have screen shots.  I'm new to this forum.  Does it have the capability to upload a file?  It is an intermittent problem where A LOT of characters like these below (which include a lot of small boxes in between) show up at the top of some of the web pages in our application.  The rest of the web page loads fine, bu...

Implementing .Net Form into an web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

Displas ANSI character BIG5 in Web Form
Having problem to show correct Chinese character (Big5) ANSI code in the Web Form. It display correctly if I run on the PB11 Window Application. Background: Database: SQL Server 2005 Connection: [Database] DBMS=SNC SQL Native Client(OLE DB) ServerName=SQLServerDatabase=DTSITF LogId=iml LogPassword=iml01 Prompt=0 DBParm=Database='DBNAME',TrimSpaces=1,AppName='IML Track' Column Type: char(30) Data Stored: in ANSI BIG5 ...

Web resources about - too many characters in character literal -

Dilbert (character) - Wikipedia, the free encyclopedia
Dilbert is a fictional character and the main character and protagonist of the Dilbert comic strip . He is a white collar office worker who has ...

Zoolander 2 faces boycott over Benedict Cumberbatch's transphobic character
The anticipated Zoolander sequel has been blasted as "hateful" in a petition agitating for the film to be boycotted for enforcing dangerous perceptions ...

Meet Crusoe, Ottawa's best-selling 'small dog with a big character' - CTV News
With a New York Times best-selling book and 20 million YouTube hits under his belt, Crusoe may just be the world's most interesting dog.

Sainsbury's Brings Beloved Kids' Character to Life and Tops U.K. Book Sales
This week saw an unexpected new title shoot to the top of the U.K's official book charts: "Mog's Christmas Calamity," by children's author Judith ...

Friday Evening Open Thread: Cartoons & Cartoon Characters
Charlie Hebdo's new cover: "They've got guns. Screw them, we've got champagne" — Katy Lee (@kjalee) November 17, ...

George Lucas says if he could be any 'Star Wars' character, he'd be Jar Jar Binks
Of all the characters in "Star Wars," creator George Lucas says he'd be Jar Jar Binks in a v ideo for Vanity Fair . "I like all the characters," ...

Lives cut short by Paris attacks remembered in 140 characters
As Parisians remember the victims of last week's terror attacks with candles and flowers, another kind of memorial is unfolding on social media ...

Is Benedict Cumberbatch’s character in ‘Zoolander 2′ actually transphobic?
... prominently in the second trailer. I assumed Benedict would be playing himself or some version of himself, but he’s playing a real character, ...

Arrow Is Bringing Back A Major Character, Get The Details
When Arrow returns from its midseason hiatus next year, this character who hasn’t been seen since last season will return. Spoiler alert! If ...

Take a look at the full cast of Indivisible's guest characters
... PR to save an underdog developer (and its legions of fans) from painful disappointment. Indivisible 's finely curated list of guest characters ...

Resources last updated: 11/27/2015 3:53:36 PM