I'm having a problem using Javascript inside a link button in C# in Visual Studio 2010.

Koudai2008

Estimable
Dec 5, 2014
2
0
4,510
I'm still new to ASP.NET, but I've worked in classic ASP a bit beforehand.

I worked a tutorial that I found on youtube about how to create a social networking site (not the next Facebook, just something to get me started), but I've run into a problem when trying to use javascript in a link button.

My code looks like this:
<script src="assets/script/Javascript.js" type="text/javascript"></script> - (inside the head tag)

<div id="start" style="display: none;">This is the start menu.</div> - (inside the body tag)

<asp:LinkButton ID="LinkButton1" runat="server" OnClick="javascript:switchVisible('start');javascript:start('start')">Press Start:</asp:LinkButton> - (inside the body tag)

When I try to debug the site, I get an error that looks like this:
Compiler Error Message: CS1012: Too many characters in character literal

I've also tried using the asp:HyperLink and asp: DynamicHyperlink. I saw on other websites where they told someone to replace "onClick" with "onClientClick" and I tried that, but still didn't work. I even tried moving the javascript into the asp file, but still nothing.

What should I do?
 

Koudai2008

Estimable
Dec 5, 2014
2
0
4,510


Thanks for the quick reply.

I had a look at that page and I couldn't figure out that DataBinder.Eval thing. I it on some other websites, but some of the people asking about it were asking how to put single quotes around it.

As I've said, I'm still new to ASP.NET, so I've never even heard of DataBinder.Eval. I've worked in classic ASP, but that was only when I was working a tutorial on how to make a simple guestbook with no user login or anything.

Thanks for trying to help.