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("hdnAddInfoIndex");

 

for(var x=0; x<radiobuttonlist.length;x++)

{

selectedValue = radiobuttonlist[x].value;

}

 

for(var i =0; i<needAdditionalInfo.length; i++)

{

if(needAdditionalInfo[i]==selectedValue)

document.getElementById("txtAdditionalInfo").style.visibility="visible";

else

document.getElementById("txtAdditionalInfo").style.visibility="hidden";

}

}

 

 

 


+
Lvl FIVE THOUSAND DRAGON MASTER SOFTWARE ENGINEER
my friends call me MOI
0
moises
4/3/2008 9:52:17 PM
asp.net.client-side 24353 articles. 1 followers. Follow

15 Replies
867 Views

Similar Articles

[PageSpeed] 1

moises.dl:
thats my javascript error it wont build and this is my code
 

Please indicate the line that is throwing the exception.

Also could you please post the rendered output of the radiobuttonlist and the hidden field (paste the source that's sent to the browser) 


-- Sam Critchley

"Wise man say 'forgiveness is divine, but never pay full price for late pizza." - TMNT

shivam.com.au
0
worldspawn
4/3/2008 10:51:01 PM

there is nothing in the hidden field its just like a variable for clientside, the hidden fields i found out is a panel.visable set to false with a textbox inside  

it does not have a line where it throws an exception it wont run it wont compile  i also tried this

rblOffers.Attributes.Add("onclick", "CheckAdditionalInfo();");

 and took it off of the control itself

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="OfferLayout.aspx.cs" Inherits="OfferLayout" %>

<%@ Register TagPrefix="uc1" TagName="Header" Src="Header.ascx" %>
<%@ Register Assembly="ProgressBarControl" Namespace="ProgressBarControl" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Offer Selector</title>
    <link href="styles/StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <input type="hidden" runat="server" id="hdnAddInfoIndex" />
    <uc1:Header ID="Header" runat="server"></uc1:Header>
    <br />
    <br />
    <table cellpadding="5" width="660px" border="0" align="center" bgcolor="#ECECEC">
        <tr>
            <td colspan="2">
                <cc1:WebCustomControl1 ID="WebCustomControl11" runat="server" Total="42" Value="0" />
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <h5 style="font-style: normal; font-weight: bold; text-transform: capitalize; font-family: Arial, Helvetica, sans-serif;">
                    <asp:Label ID="lblService" runat="server" Font-Bold="True" Text="SERVICE TYPE"></asp:Label>
                     ||
                    <asp:Label ID="lblCustomerSegment" runat="server" Font-Bold="True" Text="SEGMENT"></asp:Label>
                     ||
                    <asp:Label ID="lblPanelName" runat="server" Font-Bold="True" Text="PANEL NAME"></asp:Label></h5>
            </td>
        </tr>
        <tr>
            <td width="40%">
                <table cellpadding="10">
                    <tr>
                        <td>
                            <asp:Image ID="imgProgress" runat="server" />
                        </td>
                    </tr>
                </table>
            </td>
            <td>
                <table width="100%">
                    <tr>
                        <td>
                            <asp:Label ID="lbWelcome" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:Label ID="lblOfferError" runat="server" ForeColor="Red"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:RadioButtonList ID="rblOffers" runat="server" AutoPostBack="false" 
                                  >
                            </asp:RadioButtonList>
                            <asp:Panel ID="pnlAdditionalInfo" runat="server" Width="100%" Visible="false">
                                <table cellpadding="10">
                                    <tr>
                                        <td>
                                            <asp:Label ID="lblOffer" runat="server"></asp:Label>
                                             Additional Info:<br />
                                            <asp:TextBox ID="txtAdditionalInfo" runat="server" TextMode="MultiLine" Width="250px"
                                                Height="50px"></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </asp:Panel>
                            <br />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td>
                 
            </td>
        </tr>
        <tr>
            <td colspan="2" align="center">
                <br />
                <br />
                <asp:Button ID="btnSubmit" runat="server" Text="Submit" Width="80px" OnClick="OnBtnSubmitClick" />
                <br />
                <br />
                <br />
                <div id="divStatus" style="color: #FF0000">
                </div>
            </td>
        </tr>
    </table>
    <p>
         </p>

    <script type="text/javascript" language="javascript">
 function OnProgress(progressBar)
{
	var extraData = progressBar.getExtraData();
	if (extraData)
	{
		var div = document.getElementById("divStatus");
		div.innerHTML = extraData;
	}
}

function CheckAdditionalInfo()
{
    var needAdditionalInfo = new Array();
    var selectedValue = '';
    var radiobuttonlist = document.getElementById("rblOffers");
    needAdditionalInfo = document.getElementById('hdnAddInfoIndex');
    
    for(var x=0; x<radiobuttonlist.length;x++)
    {
        selectedValue = radiobuttonlist[x].value;
    }
    
    for(var i =0; i        document.getElementById('pnlAdditionalInfo').style.visibility='visible';
        else
        document.getElementById('pnlAdditionalInfo').style.visibility='hidden';
    } 
}
    form>
</body>
</html>
 
+
Lvl FIVE THOUSAND DRAGON MASTER SOFTWARE ENGINEER
my friends call me MOI
0
moises
4/3/2008 11:02:26 PM

Sorry I'm stupid. Should have seen this right away.

OnSelectedIndexChanged="CheckAdditionalInfo('rblOffers')"

This is invalid. You want to call a client side event handler but you actually defining a server side event handler (in an invalid way, hence the compile error). You can try putting onclick on the tag instead. You will need to do this in code not the ascx/aspx because you need to know the ClientID of rblOffers.

rblOffers.Attributes["onclick"] = string.Format("CheckAdditionalInfo('{0}')", rblOffers.ClientID);

Oh and Hungarian notation is dead. Let it go. :)


-- Sam Critchley

"Wise man say 'forgiveness is divine, but never pay full price for late pizza." - TMNT

shivam.com.au
0
worldspawn
4/3/2008 11:31:00 PM

i just follow standars... haha ill try that now i have a bunch of jumbled up code that i have to work through


+
Lvl FIVE THOUSAND DRAGON MASTER SOFTWARE ENGINEER
my friends call me MOI
0
moises
4/7/2008 3:53:57 PM

i have another question you can probably help me with, onpage load i look in the db to show these chunks of html if a field in the db is a certain value then im also going to show a textbox inside the html where the user can put some input.... right now i have it dynamically checking the field and then adds the textbox if valid, but the textbox wont showup, the html is there but no control

 

string tempHtml = "</br><div style='border: 1px coral solid;'>";

DataRow row = ds.Tables[0].Rows[i];

tempHtml = row["strOfferHeader"].ToString() + tempHtml + row["strOfferDetail"].ToString();

bAdditionalInfo = Convert.ToBoolean(ds.Tables[0].Rows[i]["BlnAdditionalInfoNeeded"]);

if (bAdditionalInfo)

{

//add additional info box to html

tempHtml = tempHtml + "<table cellpadding='10'><tr> <td></br> &nbsp;Additional Info:<br /><asp:TextBox ID='txtAdditionalInfo" + row["intOfferid"].ToString() + "' runat='server' TextMode='MultiLine'Width='250px' visible='true' Height='50px'></asp:TextBox> </td> </tr> </table>";

//lblOffer.Text = ds.Tables[0].Rows[i]["strOfferDetail"].ToString();

}

tempHtml +=
"</div>";

rblOffers.Items.Add(new ListItem(tempHtml, row["intOfferid"].ToString()));


+
Lvl FIVE THOUSAND DRAGON MASTER SOFTWARE ENGINEER
my friends call me MOI
0
moises
4/7/2008 8:02:24 PM

There are a few misconceptions at work here. For starters an asp.net radiobuttonlist renders as a table by default containing radio buttons. I would assume (though I haven't tested it) that document.getElementById("rblOffers") will give you a reference to the table which won't have a length. Once you have a reference to the table the easiest way to check all the radio buttons would be something like:-

var radios = radiobuttonlist.getElementsByTagName("input");
for (i=0;i<radios.length;i++)   {
   if (radios[i].type=="radio")   {
        //do something where radios[i] is the found radio button.
   }
}

You can't expect javascript to deal with asp.net controls in the same way. The important thing with any asp.net controls is to see what html a control renders. i.e. open the site in the browser and view source.

Also adding a string to the page containing "<asp:textbox " etc. will not work because asp.net controls are server controls which must be declared within the aspx page or added progamatically. For example if I have a panel with an id of "content" I would add a textbox like so:-

dim tb as new textbox
tb.textmod = multiline
tb.id = "textbox1"
content.controls.add(tb)

Generally if you add a control using the method above you would do it in the page init event for example to ensure it is included in the viewstate and if  asuer submits content in it you will be able to get the value entered.


Brian O'Connell (MCAD) - http://www.systemdotweb.com
0
BrianOConnell
4/7/2008 8:39:40 PM

so what do you think of this approch,

im adding just a <input> field when my radiobuttonlist adds items, then on submit click i have a hiddenfield in my html which holds the text info which i will get on serverside by looking up the hiddenfield,


+
Lvl FIVE THOUSAND DRAGON MASTER SOFTWARE ENGINEER
my friends call me MOI
0
moises
4/7/2008 8:42:41 PM

hey brian i didnt really get what you were saying the other day but after testing with firefox javascript debugger i get what youre saying and im gonna try it out thanks man!


+
Lvl FIVE THOUSAND DRAGON MASTER SOFTWARE ENGINEER
my friends call me MOI
0
moises
4/8/2008 3:48:35 PM

i got everything working i just cant get the value out of the txtadditional input field... when i do 

txtAdditional.value i get null

 

i notice in the debugger i have to click a - (minus) sign then under 0 is more properties in which there is a value which is my text...


+
Lvl FIVE THOUSAND DRAGON MASTER SOFTWARE ENGINEER
my friends call me MOI
0
moises
4/8/2008 3:53:35 PM

defaultValue is not a property of a html radio button. You just want the value property I think - myradio.value.


Brian O'Connell (MCAD) - http://www.systemdotweb.com
0
BrianOConnell
4/8/2008 4:24:41 PM

yea im just poking around i need to get the value out of the <input> field


+
Lvl FIVE THOUSAND DRAGON MASTER SOFTWARE ENGINEER
my friends call me MOI
0
moises
4/8/2008 4:35:04 PM

this is what it looks like  

  </div>Additional Info </br><input type='text' name='InfoAdd1'></input></div></label></td>


+
Lvl FIVE THOUSAND DRAGON MASTER SOFTWARE ENGINEER
my friends call me MOI
0
moises
4/8/2008 4:43:18 PM

Setup a counter while looping through the radiobuttons:-

var cnt = 0;

....when you check the type and it is radio:-
cnt+1;

the textbox id will be "InfoAdd" + cnt.

Bear in mind though that if you host the page in a masterpage or user control this id will be affected. Viewing the source will show you how. Often it something like mymasterpage_mycontentpage_InfoAdd1 where mymasterpage is the name of the masterpage etc. asp.net does this to ensure unique id values in elements. i.e. I could have a texbox in the masterpage called textbox1 and one in my page called textbox1 but this renaming by asp.net means both will have different id values in the rendered html. So you would need to take it into account:-

"mymasterpage_mycontentpage_InfoAdd" + cnt


Brian O'Connell (MCAD) - http://www.systemdotweb.com
0
BrianOConnell
4/8/2008 4:56:37 PM

Add an ID attribute as:
     <input type='text' id='InfoAdd1' name='InfoAdd1' />

Then on client-side:
     <script type="text/javascript">
     <!--
     function onButtonClick()
     {
          var textValue = document.getElementById('InfoAdd1').value;
          alert(textValue);
     }
     // -->
     </script>

And server-side:
     string textValue = this.Request.Form["InfoAdd1"];
     this.Response.Write("textValue: " + textValue + "<br>");

NC...

0
NC01
4/8/2008 5:01:42 PM

thanks man you were alot alot of hep!!! for anyone who is interested in how to get selected values from a radiobuttonlist on clientside .... here it is

 

function setAdditionalInfo()

{

var rbl = document.getElementById("rblOffers");

 

 

var radios = rbl.getElementsByTagName("input");for (i=0;i<radios.length;i++)

{

if (radios[i].type=="radio")

{

var myradio = radios[i];

if(myradio.checked == true)

{

var strTextId = "InfoAdd"+myradio.value;

}

}

}

 

var txtAdditional = document.getElementById(strTextId);var hddnField = document.getElementById("hdnAdditional");

hddnField.value=txtAdditional.value;

 

}


+
Lvl FIVE THOUSAND DRAGON MASTER SOFTWARE ENGINEER
my friends call me MOI
0
moises
4/8/2008 5:12:03 PM
Reply:

Similar Artilces:

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

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='+strin...

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

Jscript, moving from client-side to server-side (.NET)
Hey all I’m working translating a web-app written in client-side Jscript to run on the server-side as JScript.NET. Without needing to get too specific, I am using Jscript because the original page aggregated raw data to produce statistical results (this was done dynamically based on user 'sort-by' options). The final output is an html report that can be emailed. Because this is currently being done on the client side, as the raw data grows the load-time grows as well (to the point that has almost become unusable). I’m posting here to see if anyone has any experi...

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

Validation Controls in .NET ( Client side or server side?)
 i have a very basic question. We have all these validation controls in asp.net ( required field, range validator and others)..my question is the required field validator is a server side control. So does that mean that it does a post back?..is it client side or server side control  The only controls that post back are buttons and other inputs where you set AutoPostback="True", such as a dropdownlist or a textbox.  Another way of posting back is using an UpdatePanel and placing a trigger in it for a specified control and/or event. All controls are considered clien...

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

When to use client side varidation and server side varidation in .net?
In .net or classic web application we can varidate user data either on client isde or server side. How to select which side varidate to be used? Thanks! Generally, I use both client and server validation. I make sure the input is in the correct format and reasonably valid on the client, then I verify the data on the server. The extent of validation also depends on the type of data that I need to validate.Here are a few references:Validating ASP.NET Server ControlsIntroduction to Validating User Input in Web FormsClient-Side Validation for ASP.NET Server ControlsSecurity Checklist...

communication between client side(java script) and server side in .net project
I have a question which is, when building a .net project, we are able to use server side code and client side code(java script). How do they communicate? Thanks Client Side coding works with the WebBrowser. So when ever you write client side code you have to keep browser compatability in your mind and you have to code. Server Side code works with Web Server (IIS) and it's ASPNET ISAPI's. The won't directly communicate with each other. But using AJAX you can all server side code from Client Side! Example article on Ajax@ http://www.devarticles.com/index2.php?option=content&task=...

.NET for client side?
Is this the idea of "Atlas" but using JavaScript rather than another technology? Atlas's goal is to abstract various browser implementations of DOM API and to ease out the developer's job to write rich client applications. Atlas hence makes use of the existing all-browser supported JavaScript to achieve this. Thanks for your reply.Let me convey my idea differently: I would like to author client side code using a class system. I recognise that Atlas is a technology for producing JS code, much in the same way that ASP.NET produces HTML for the browser.Will Atlas be m...

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

List of client side function of extenders and controls for client side
Hello All,I am using AJAX control toolkit for my current project. Now I need to find out what client side functions I can call on an extender. Lets say I am using a PopControlExtender. Now I want to show the popup from a JS funtions.If I can do a guess then it would be something like this$find('ppce').show();From where I can find what client side functions I can call on those extensders. This is really a frusterating thing. I learn about extenders only from Learn tutorials, no help here and there. Can anybody please tell me where are documentations about all the extenders in the tool...

Side by Side Execution of .net v1.1 and .net v2.0
Hi i am new bie to asp.net 2.0.Till date i have been developing projects using VS.Net 1.1 and now i hv decided to upgrade to new version 2.0.Now i want to run and develop my projects using any of the versions as desired.My question is that can i install vs 2.0 without updating the previous version and will i be able to develop and run my applications in any of the versions as desired.i have been known that we can run these versions side by side(i.e. one application can use 1.1 and other 2.0),but can we do side by side development as well(i.e. one application can use 1.1...

Web resources about - too many characters in literal - asp.net.client-side

List of Killzone characters - Wikipedia, the free encyclopedia
Cpl. Dante Garza is a loyal, optimistic and likable character- an effective team player. A close companion of Sev, the pair have served together ...

Why Coke Is Sticking With These Giggling Characters For Chinese New Year
... it wanted to find a symbol that would have that same long-term appeal in China, so it went back to the archives. It brought out some characters ...

Cut ‘Star Wars: The Force Awakens’ scene reveals a new character’s major powers
... one of the many Star Wars movies that will hit cinemas by the end of this decade. One of the best things about the movie was its new characters ...

Jack & Coke renamed "The Lemmy" by Food & Beverage magazine; Lemmy now a GTA V character
by Rob Sperry-Fromm In the wake of Lemmy's passing, tributes to the Motorhead frontman have come from all over the place, including a petition ...

A deleted scene from 'Star Wars: The Force Awakens' reveals a new character's awesome power
Maz Kanata's castle plays a larger part in "The Force Awakens" than the character herself, but she's more powerful than you realized watching ...

22 Marvel Characters Ready For The Big Screen
22 Marvel Characters Ready For The Big Screen - If you think the Marvel Cinematic Universe has added all the characters it possibly can, think ...

Nintendo promises to bring characters you love to mobile
... company promises it has greater things up its sleeve for 2016. Nintendo president Tatsumi Kimishima has confirmed plans to bring the characters ...

‘Jessica Jones’ Showrunner On Season 2: “I Just Want It To Be About Her Character” – TCA
Given that Daredevil was renewed two weeks after the show’s April premiere, you’d be forgiven for thinking that its successor, the hugely acclaimed ...

'Five Nights At Freddy's World' New Gameplay Teasers Reveal Story Clues And Pig Boss Character
"Five Nights At Freddy's World" releases next month, and new teasers are here to hype up the incoming launch. Check out the new boss and story ...

Guilty Gear Xrd: Revelator is getting yet another new character in Kum Haehyun
... a triumphant return in the near future, it looks like there's a newcomer on the block for Guilty Gear Xrd: Revelator Kum Haehyun. this character ...

Resources last updated: 1/20/2016 4:33:01 AM