Hi,
I'm making a web control which is a table of a few contacts, each contact row having a button to view or edit the contact depending on permissions allowed.
The whole roles and permissions bit is sorted. what my problem is is accessing the visible property of the buttons on the control (well they are images with hyperlinks really.)
Within the Datalist and tables in the control I have a hyperlink and image for each 'button'. My code is supposed to test whether a Boolean (the current value is hardcoded during development) is tru or not and manipulate the visible property of the ViewImage and ViewLink controls respectively.
For some reason ViewLink and ViewImage will not be recognised by the compiler. Does anyone understand why?
My code is below.
The Code for my control is here:
I'm making a web control which is a table of a few contacts, each contact row having a button to view or edit the contact depending on permissions allowed.
The whole roles and permissions bit is sorted. what my problem is is accessing the visible property of the buttons on the control (well they are images with hyperlinks really.)
Within the Datalist and tables in the control I have a hyperlink and image for each 'button'. My code is supposed to test whether a Boolean (the current value is hardcoded during development) is tru or not and manipulate the visible property of the ViewImage and ViewLink controls respectively.
For some reason ViewLink and ViewImage will not be recognised by the compiler. Does anyone understand why?
My code is below.
The Code for my control is here:
VB.NET:
<asp:DataList ID="ContactsDataList" runat="server" Width="98%">
<HeaderTemplate>
<asp:Table ID="AddContactTable" runat="server" CssClass="iconcontainer">
<asp:TableRow>
<asp:TableCell>
<asp:HyperLink ID="AddLink" runat="Server" NavigateUrl="#" ><asp:Image ID="AddImage" runat="server" ImageUrl="~/Common/Images/layout/Add.gif" AlternateText="Add Contact" /></asp:HyperLink>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:Table runat="server" ID="ContactsTableTop" CssClass="singletabletops">
<asp:TableRow>
<asp:TableCell><strong>Contacts</strong></asp:TableCell>
<asp:TableCell>results:</asp:TableCell>
<asp:TableCell>jump to:</asp:TableCell>
</asp:TableRow>
</asp:Table>
<table class="detail">
<tr class="gridbodytr">
<th class="gridbodyth">Contact:</th>
<th class="gridbodyth">Tel:</th>
<th class="gridbodyth">Detail:</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr class="gridbodytr">
<td class="gridbodytd"><asp:Label ID="ContactName" runat="server" Text=""><%#Eval("Forename") & " " & Eval("Surname")%></asp:Label></td>
<td class="gridbodytd"><asp:Label ID="ContactTel" runat="server" Text=""><%#Eval("Telephone1")%></asp:Label></td>
<td class="gridbodytd" nowrap="nowrap">
<asp:HyperLink ID="ViewLink" runat="server" NavigateUrl="#"><asp:Image ID="ViewImage" runat="server" ImageUrl="~/Common/Images/layout/view.gif" AlternateText="View Contact" /></asp:HyperLink>
<asp:HyperLink ID="EditLink" runat="server" NavigateUrl="#"><asp:Image ID="EditImage" runat="server" ImageUrl="~/Common/Images/layout/Edit.gif" AlternateText="Edit Contact" /></asp:HyperLink>
<asp:HyperLink ID="DeleteLink" runat="server" NavigateUrl="#"><asp:Image ID="DeleteImage" runat="server" ImageUrl="~/Common/Images/layout/Delete.gif" AlternateText="Delete Contact" /></asp:HyperLink>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:DataList>
VB.NET:
Imports CommonDAL1TableAdapters
Imports Address
Partial Class Controls_Address_Contacts
Inherits System.Web.UI.UserControl
Dim AddressType As String
Dim ReferenceId As Integer
'Dim RoleAccess As Object = CType(Session("UsersAccess"), Object)
Dim ViewButton = ContactsDataList.FindControl("viewimage")
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
End Sub
Public Sub GenerateDataList( _
ByVal AddressType As String, _
ByVal ReferenceId As Integer, _
ByVal ObjectId As Integer)
'Declare a new Address Object
Dim Contacts As New Address
Dim View As Boolean = False
' Set Source and bind the DataGrid
ContactsDataList.DataSource = Contacts.SelectAddressByRefAndType(AddressType, ReferenceId)
ContactsDataList.DataBind()
' Check Role permissions
If View Then
ViewLink.Visible = True
ViewImage.Visible = True
Else
ViewLink.Visible = False
ViewImage.Visible = False
End If
End Sub
End Class