[英]The server tag is not well formed - hyperlink databound
I have a formatting issue with my hyperlink, it works OK with the text part along so I know it's an issue with the JavaScript but don't know what the problem is. 我的超链接存在格式问题,文本部分也可以正常工作,所以我知道这是JavaScript的问题,但不知道是什么问题。
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="hypCustType" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "CustType") %>'
NavigateUrl="javascript:sendval('<%# DataBinder.Eval(Container.DataItem, "CustType") %>');">
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
'The problem is, you have closed the string in the NavigateUrl Property. '问题是,您已经关闭了NavigateUrl属性中的字符串。 You should use
'
or \\"
inside of inline code to not end the string. So you should try this: 您应该在内联代码中使用
'
或\\"
不结束字符串。因此,您应该尝试以下操作:
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="hypCustType" runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, "CustType") %>'
NavigateUrl="javascript:sendval('<%# DataBinder.Eval(Container.DataItem, \'CustType\') %>');">
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
像这样尝试:
<asp:HyperLink ID="hypCustType" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "CustType") %>' NavigateUrl='<%# "javascript:sendval(\"" + DataBinder.Eval(Container.DataItem, "CustType") + "\");" %>'></asp:HyperLink>
replace the asp:hyperlink with a normal html tag link: 用普通的html标签链接替换asp:hyperlink:
<a href="javascript:sendval('<%# DataBinder.Eval(Container.DataItem, "CustType") %>');">
<%# DataBinder.Eval(Container.DataItem, "CustType") %>'</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.