Too many characters in character literal?

偶尔善良 提交于 2019-12-05 10:33:57

Is DivAc('griddiv') a javascript function? Then you have to use OnClientClick instead of OnClick.

OnClick is reserved for .NET functions. With OnClientClick you generates the OnClick-attribute in HTML.

This is probably a bit confusing.

So this is what you have to do:

<asp:LinkButton ID="LinkButton1" OnClientClick="DivAc('griddiv')" Font-Size="Smaller"  runat="server" CommandName='<%# Eval("harf").ToString().ToUpper()%>'><%# Eval("harf").ToString().ToUpper() %></asp:LinkButton>

The immediate issue is that you placed a string (griddiv) in character quotes (a single quote, in C#, is for a single character only). You would need to write something like OnClick="DivAc(\"griddiv\")"

BUT

OnClick is a server-side event handler that takes the name of a public or protected function that takes (object,EventArgs) and returns void. So this won't compile anyway.

Where is DivAc? In JavaScript? If so, you want OnClientClick, in which case you can leave the single and double quotes as they are.

ChrisBD

I think that your error is here:

CommandName='<%# Eval("harf").ToString().ToUpper()%>'><%# Eval("harf").ToString().ToUpper() %></asp:LinkButton>

I think that its should be:

CommandName='<%# Eval("harf").ToString().ToUpper()%'></asp:LinkButton>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!