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