Tags: articles, findcontrol, loginview, loginviewfindcontrol, method, net, null, online, returning, security, suggested
LoginView.FindControl returning null
I am having problems with the FindControl method of the LoginView. From articles I have read online, it is suggested that I should be able to use FindControl to access controls nested within a LoginView.
In my situation, I have the following markup:
</ContentTemplate> </asp:RoleGroup"> </RoleGroups>
And the VB.Net code in Page_Load:
DimtheLabelAs Label =CType(Me.lgBookingEngineByRole.FindControl("lblTest"), Label)
The problem is that theLabel is coming back as Nothing. This is the same problem for any controls I have within this ContentTemplate, including labels and repeaters.
I have tried to find a .FindControl further down the hierarchy, such as lgBookingEngineByRole.<something>.FindControl() but I cannot find anything like this which might be appropriate.
Any ideas as to why I am getting a null reference?
Leave a comment...
- 1 Comments
I managed to solve my own problem: I was not a member of the role "hdn-BookingFinancial" which I had specified as the required role.
I added myself to this role and now it works perfectly.#1; Sat, 05 Jan 2008 23:48:00 GMT