【问题标题】:inserting dynamic URL string in Attributes property在 Attributes 属性中插入动态 URL 字符串
【发布时间】:2015-03-08 01:28:21
【问题描述】:

我试图让 url 出现在下面代码中的 trackOutboundLink('') 中。我继承了这个网站,自从我搞砸 vb 以来已经有一段时间了。任何意见,将不胜感激。谢谢

        If DBReader("URL").ToString <> "" Then
            CustWebSite.NavigateUrl = DBReader("URL").ToString
            CustWebSite.ToolTip = DBReader("URL").ToString.Replace("http://", "")
            CustWebSite.Text = DBReader("URL").ToString.Replace("http://", "")
            CustWebSite.Attributes("onclick") = "trackOutboundLink(''); return false;"
            CustWebsiteDiv.Visible = True
        Else
            CustWebsiteDiv.Visible = False
        End If

我正在寻找的最终结果是: http://www.testsite.com');返回 false;" href="http://www.testsite.com">www.testsite.com

除了显示在 url 之外的所有作品

onclick="trackOutboundLink('http://www.testsite.com'); 返回 false;"

部分。

感谢您的帮助。

【问题讨论】:

    标签: .net vb.net properties attributes


    【解决方案1】:

    VB.NET 中的字符串连接与 C# 中的工作方式相同。 CustWebSite.Attributes("onclick") = String.Format("trackOutboundLink('{0}'); return false;", DBReader("URL"))

    另外,与其多次调用DBReader("URL"),不如将​​第一次调用结果存储在一个局部变量中,并在所有后续语句中根据需要使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-24
      • 2011-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多