Compiler Error Message: CS1012: Too many characters in character literal

Posted on 2006-03-30
Last Modified: 2012-05-05
This code as an event on an asp:DropDownList ctrl works fine:

OnBlur='WorkOutTotals("revIncreaseTB", "revIncreaseWeightTB", "revIncreaseTotalTB", 1 )'

whereas the same code applied to a selected index change, ie,

OnSelectedIndexChanged='WorkOutTotals("revIncreaseTB", "revIncreaseWeightTB", "revIncreaseTotalTB", 1 )'

gives me a compilation error: Compiler Error Message: CS1012: Too many characters in character literal

Any ideas?
(I have tried switching the single and double quotes around!)
Question by:blitzoid
    LVL 24

    Accepted Solution

    Remember that OnBlur is a client side event and not a serverside, so it will just emit it to the browser, but the OnSelectedIndexChanged is a server side event and it just wants a function name of a server side method, so the ("revIncreaseTB... etc) is not going to fly because you cannot have a ( in a function name.

    So if you want to have it on the client side you would use the onchange='WorkOutTotals("revIncreaseTB", "revIncreaseWeightTB", "revIncreaseTotalTB", 1 )' instead.

    LVL 10

    Expert Comment

    OnSelectedIndexChanged is a server side event.
    OnBlur is javascript event, client side event.

    So, to make this work you need to change "OnSelectedIndexChanged"  to "OnChange".

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now