Too many characters in character literal - what does it mean, and how to fix?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zman77
    New Member
    • Sep 2007
    • 17

    Too many characters in character literal - what does it mean, and how to fix?

    Hello,

    I have a bunch of Image Buttons in my code. When I leave them as they are, I can build my project without problems. However, when I add OnClick to an image button, I get the error:
    Too many characters in character literal

    For example, the following builds with no problems:
    Code:
    <asp:imagebutton id="myImgBtn" style="Z-INDEX: 102; LEFT: 82px; POSITION: absolute; TOP: 8px" runat="server" ImageUrl="images/myBtns/order.gif" BorderStyle="None" ToolTip="Order"></asp:imagebutton>
    That same line, with OnClick added, does not build, and I get the above mentioned error:
    Code:
    <asp:imagebutton id="myImgBtn" style="Z-INDEX: 102; LEFT: 82px; POSITION: absolute; TOP: 8px" runat="server" ImageUrl="images/myBtns/order.gif" BorderStyle="None" ToolTip="Order" OnClick="dcsMultiTrack('DCS.dcsuri','/ordering/orderbtn', 'WT.ti','Order')"></asp:imagebutton>
    How can I fix this? I'm trying to add the OnClick code in order to keep stats of button presses (we use webtrends).
    Why exactly is that error happening?

    I googled for a solution, and found that I could add an attribute to the button in my C# code. However, I was wondering if I can do this straight in asp without resorting to changing the C# code. Oh, this happens with Visual Studio 2005. My machine has the following .Net frameworks: 1.1, 2.0, 2.0 SP2, 3.0 SP2, 3.5 SP1 (also 2.0 SDK and 1.1 SDK)

    Thanks for any help.
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Are you trying to use a Javascript when you click the imagebutton?

    OnClick is a server side event. If you want your client side scripting to catch the event, you want to use OnClientClick.

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      Originally posted by insertAlias
      Are you trying to use a Javascript when you click the imagebutton?

      OnClick is a server side event. If you want your client side scripting to catch the event, you want to use OnClientClick.
      I didn't even catch that, nice one

      Comment

      Working...