字符文字中的字符太多?
你能告诉我这段代码有什么问题吗???快要疯了!!!
<asp:LinkButton ID="LinkButton1" OnClick="DivAc('griddiv')" Font-Size="Smaller" runat="server" CommandName='<%# Eval("harf").ToString().ToUpper()%>'><%# Eval("harf").ToString().ToUpper() %></asp:LinkButton>
错误:字符文字中的字符太多...:(
Can you tell me please what is wrong with this code??? About to getting crazy!!!
<asp:LinkButton ID="LinkButton1" OnClick="DivAc('griddiv')" Font-Size="Smaller" runat="server" CommandName='<%# Eval("harf").ToString().ToUpper()%>'><%# Eval("harf").ToString().ToUpper() %></asp:LinkButton>
Error: Too many characters in character literal... :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
DivAc('griddiv')
是 JavaScript 函数吗?那么你必须使用
OnClientClick
而不是OnClick
。OnClick
是为 .NET 函数保留的。使用OnClientClick
,您可以生成 HTML 格式的 OnClick 属性。这可能有点令人困惑。
所以这就是你必须做的:
Is
DivAc('griddiv')
a javascript function?Then you have to use
OnClientClick
instead ofOnClick
.OnClick
is reserved for .NET functions. WithOnClientClick
you generates the OnClick-attribute in HTML.This is probably a bit confusing.
So this is what you have to do:
直接的问题是您将一个字符串 (griddiv) 放在字符引号中(C# 中的单引号仅适用于单个字符)。您需要编写类似
OnClick="DivAc(\"griddiv\")"
但
OnClick 是一个服务器端事件处理程序,它采用公共或受保护函数的名称,该函数采用 (object, EventArgs) 并返回 void。所以无论如何这都不会编译。
迪瓦克在哪里?在 JavaScript 中?如果是这样,您需要 OnClientClick,在这种情况下,您可以保留单引号和双引号不变。
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.
我认为你的错误在这里:
我认为它应该是:
I think that your error is here:
I think that its should be: