如何从类中查找超链接

时间:2015-10-30 18:46:09

标签: asp.net vb.net

我正在尝试创建一个类,允许我在我的站点中设置任何超链接,以便将用户带到请求的URL或显示工具提示消息(或其他内容),让他们知道他们没有适当的配置文件类型以查看该链接。在类I中我将有一个LinkVerification子,它将在点击时从超链接中获取以下参数:

  1. 链接ID
  2. 地址
  3. 用户个人资料类型ID(有5个个人资料类型,如试用版,管理员等等。)
  4. 不允许的个人资料类型ID列表。
  5. 我原本希望通过发送超链接ID作为参数,我可以使用FindControl来设置特定的Hyperlink的NavigateURL和ToolTip成员,但到目前为止我还没有成功。我不知道该怎么做这个任务。如果有人可以提供帮助,将不胜感激!也许我想要做的是不可能的?这是我到目前为止所做的:

    Public Class LinkRestriction
    'Get the user's Profile Type and redirect them to the requested link if they are allowed to and be given a message if not.
    Public Shared Sub LinkVerification(ByVal linkID As String, ByVal Url As String, ByVal ProfileType As Integer, ByVal DisAllowed As String)
        'Convert comma separated list to a List
        Dim varRestricted As List(Of String) = ConvertStringsToList(DisAllowed, ",")
    
        'Find the control to be verified
        [some code]        
    
        If Not varRestricted.Contains(ProfileType.ToString) Then
            'Populate Tooltip of link control with message letting user know he doesn't have sufficient permissions to view this link.
            [some code]
        Else
            'send user to the request link
            [some code]
        End If
    End Sub
    
    Public Shared Function ConvertStringsToList(items As String, separator As Char) As List(Of String)
        Dim list As New List(Of String)()
        Dim listItmes As String() = items.Split(separator)
        For Each item As String In listItmes
            list.Add(item)
        Next
        Return list
    End Function
    End Class
    

0 个答案:

没有答案