?
Solved

Calling this Javascript function in OnClick

Posted on 2011-10-29
4
Medium Priority
?
303 Views
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>

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

Open in new window

0
Comment
Question by:Camillia
4 Comments
 
LVL 9

Expert Comment

by:djon2003
ID: 37051805
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

0
 
LVL 7

Author Comment

by:Camillia
ID: 37051810
let me try. thanks
0
 
LVL 15

Accepted Solution

by:
Eyal earned 2000 total points
ID: 37051866
0
 
LVL 38

Expert Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month15 days, 6 hours left to enroll

839 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