Calling this Javascript function in OnClick

Posted on 2011-10-29
Last Modified: 2012-05-12
I have a simple javascript function. I have 2 divs. I want to call the JS code in OnClick and
hide, show the div. Not sure why i get this msg

Too many characters in character literal

googled but not a concrete answer. My code is below.
<td width="310"><asp:Button ID="lbSearchSpecialty" OnClick="Show('divSpecialty'); Hide('divProvider')"   runat="server" Text="Search by Specialty" ></asp:Button></td>


 function Show(divId) {
            document.getElementById(divId).style.visible = 'visible';
        function Hide(divId) {
            document.getElementById(divId).style.visible = 'hidden';


  <div style="display:none" id="divProvider">
       <uc1:providerSearch runat="server"  ID="ucProvider" />

    <div style="display:none" id="divSpecialty">
       <uc1:providerSpecialty runat="server" ID="ucSpecialty" />

Open in new window

Question by:Camillia
    LVL 9

    Expert Comment

    Three things.

    First, try to add a semi-colon at the end (onclick="Show('divSpecialty'); Hide('divProvider');").
    Second, try to add "javascript:" in front (onclick="javascript:Show('divSpecialty'); Hide('divProvider');").
    Third, isn't the attribut runat=server makes the onclick event be in VB code instead ? Not sure about that though, while it's making some time I didn't do ASP

    LVL 7

    Author Comment

    let me try. thanks
    LVL 15

    Accepted Solution

    LVL 38

    Expert Comment

    by:Tom Beck
    @Eval has it. Simply change from OnClick to OnClientClick and it will work.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    745 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

    15 Experts available now in Live!

    Get 1:1 Help Now