access to controls in loginview

3k Views Asked by At

I have a loginview in my webform that has several Items. I want to access to one of them in code behinde and disable it.

for exampe, one of loginview items is:

                    <asp:LoginView ID="LoginView8" runat="server">
                        <LoggedInTemplate>
                            <asp:Image ID="imgAssetTransport" runat="server" SkinID="AssetTransportDisable" meta:resourcekey="imbAssetTransport" />
                        </LoggedInTemplate>
                        <RoleGroups>
                            <asp:RoleGroup Roles="AssetUser,AssetAdmin">
                                <ContentTemplate>
                                    <asp:HyperLink ID="**imbAssetTransport**" runat="server" SkinID="AssetTransport" NavigateUrl="~/Asset/Pages/AssetTransportDetailList.aspx" meta:resourcekey="imbAssetTransport" />
                                </ContentTemplate>
                            </asp:RoleGroup>
                        </RoleGroups>
                    </asp:LoginView>

Now I want to access "imbAssetTransport", and disable it, when the user views my page.

1

There are 1 best solutions below

1
Glory Raj On BEST ANSWER

you can try like this....

NOTE: this is example how to access lable control that was placed inside login view..

    <asp:LoginView ID="lgBookingEngineByRole" runat="server">
  <RoleGroups>
    <asp:RoleGroup Roles="hdn-BookingFinancial">
      <ContentTemplate>
        <asp:Label ID="lblTest" runat="server" />
      </ContentTemplate>
    </asp:RoleGroup">
  </RoleGroups>
</asp:LoginView>

and in page load event you can put this...

Label theLabel = ((Label)(this.lgBookingEngineByRole.FindControl("lblTest")));