简体   繁体   English

将HyperLink控件更改为Href不起作用

[英]Change HyperLink Control to Href doesn't work

I have a Hyper Link control is added to panel and it worked. 我有一个Hyper Link控件已添加到面板中,并且可以正常工作。 I need to replace it as href for consistent other controls in page. 我需要将其替换为href,以实现页面中其他一致的控件。 However my script has error when I debug it in VS 2015. The error message is : "JavaScript critical error at line 333, column 255 in http://localhost:603/Order/buyerProfile.aspx?Id=42940 \\n\\nSCRIPT1002: Syntax error" 但是,当我在VS 2015中调试脚本时,我的脚本有错误。错误消息是:“ JavaScript严重错误,位于第333行, http:// localhost:603 / Order / buyerProfile.aspx?Id = 42940 \\ n \\ nSCRIPT1002的第255列:语法错误”

Would someone tell me how to fix it. 有人会告诉我如何解决它。 Thanks in advance. 提前致谢。

There is my code for HperLink control that work: 我的HperLink控件代码有效:

Dim hypOrder As New HyperLink
Dim onClick As String = "openWin('OrderForm/pop.aspx"
                onClick &= "','',500,270);return false;"
                hypOrder.Text = "Test page"
                hypOrder.Attributes.Add("onclick", onClick)
pnlLink.Controls.Add(hypOrder )

There is my code to change as href: 我的代码可以更改为href:

dim href1 as string
Dim href1 As String = "<a target='_blank'  class='body'" & "href='#'"
href1 = href1 & " onclick='openWin('OrderForm/pop.aspx','',500,270);return false;"
href1 = href1 & "'>" & Test page & "</a>"
 Dim ltLink As New Literal
 ltLink.Text = href1
 pnlSecurityFlagsLink.Controls.Add(ltLink)

I debug it the href text is : 我调试它href文本是:

  <a target='_blank'  class='body' href='#' onclick='openWin('OrderForm/pop.aspx','',500,270);return false;'>Test page </a>

You have multiple single quotes on the line inside the onclick= . 您在onclick=内的行上有多个单引号。 You have to use double quotes to make it work. 您必须使用双引号使它起作用。

href1 = href1 & " onclick=""openWin('OrderForm/pop.aspx','',500,270);return false;"">Link</a>"

To escape the " , make it a double "" 要逃避" ,请将其设为双倍""

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM