Hello,
I am finally be able to get the login name pass it through the Master page. Now I am working on the “session”. I also be able to pass the session to the Master page.
Now I stuck with passing the session to the right location in the layout template Please look at the label22.text. I am successfully session from the login page to the Master page.
But now I need your help to bring the “label22” into the layout template next to the “label2” or “log in as”.
Can you help me to fix my code please?
Here is my HTML code.
<asp:Label ID="Label22" runat="server" Text=" "> </asp:Label>
<div id="MainNav">
<div class="sitecontainer">
<div id="MainNavWrapper">
<asp:HyperLink ID="HyperLink1" NavigateUrl="../Faculty.pdf" Text="User's Guide" runat="server" target="_blank" Visible ="False"></asp:HyperLink>
<asp:LoginView ID="LoginView1" runat="server">
<AnonymousTemplate>
<asp:Label ID="Label2" runat="server" Text="Log in as:" login1="UserName"> </asp:Label>
<asp:Label ID="Label222" runat="server" Text=" "> </asp:Label>
| <a href="~/default.aspx" id="HeadLoginStatus" runat="server" color="#87cfe6">
Log Out
</a> |
</AnonymousTemplate>
<LoggedInTemplate>
|
Logged in as: <asp:LoginName ID="LoginName1" runat="server" />
|
<asp:Label ID="DividerLabel4" runat="server" Visible="False"> | </asp:Label>
<asp:LoginStatus ID="LoginStatus1" runat="server" LogoutAction="RedirectToLoginPage" />
|
</LoggedInTemplate>
</asp:LoginView>
</div>
</div>
</div>
VB Code, but then the error said that: “Object reference not set to an instance of an object.”
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Label22.Text = Session("UserLoginName")
Dim NameLogin As String = (TryCast(LoginView1.FindControl("Label222"), TextBox)).Text
If Not String.IsNullOrEmpty(NameLogin) Then
NameLogin = Label22.Text
End If
End Sub
many thanks.