[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1561
  • Last Modified:

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

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!)
1 Solution
DBAduck - Ben MillerPrincipal ConsultantCommented:
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.

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

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now