Solved

master page in asp.net

Posted on 2009-04-15
14
720 Views
Last Modified: 2012-05-07
i want when user login on page
user name will be display on master page lable


0
Comment
Question by:chandresh43
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 3
  • +1
14 Comments
 
LVL 20

Expert Comment

by:informaniac
ID: 24146831
((Label)this.Master.FindControl("lblName")).Text = " Name";
0
 
LVL 18

Expert Comment

by:carlnorrbom
ID: 24146853
Hi,

Or maybe simply just use the asp.net server control "LoginName"? Just place it somewhere in the markup of Your master page:

<asp:LoginName ID="LoginName1" runat="server" />

/Carl.
0
 
LVL 5

Author Comment

by:chandresh43
ID: 24146856
this give me error
 Object reference not set to an instance of an object.
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 5

Author Comment

by:chandresh43
ID: 24146868
and my login page in not contain master page
0
 
LVL 5

Expert Comment

by:Buginator
ID: 24147139
When your user log in, create a session:
Session["UserName"] = the username, ie from the username textbox

Make a Label in your masterpage, place it where you want to in the masterpage:
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

In the code behind file for the masterpage, MasterPage.master.cs, write the following the Page_Load event:
if (Session["UserName"] != null) Label1.Text = Session["UserName"];

Done.
0
 
LVL 20

Expert Comment

by:informaniac
ID: 24147159
Store the id in Session and in the load event of the masterpage, set the value of the label from session
0
 
LVL 20

Expert Comment

by:informaniac
ID: 24147246
Sorry Buginator...
0
 
LVL 5

Expert Comment

by:Buginator
ID: 24147340
A small correction:
if (Session["UserName"] != null) Label1.Text = Session["UserName"].ToString();

Open in new window

0
 
LVL 5

Author Comment

by:chandresh43
ID: 24149361
oh thats i don but how refresh master page
0
 
LVL 5

Expert Comment

by:Buginator
ID: 24149387
What do you mean? The code I gave you should be sufficient.
0
 
LVL 5

Author Comment

by:chandresh43
ID: 24149993
no men you dont get
there is radwindows where user enter user password
and that value go to mater page
so i want to refresh master page after session is created
0
 
LVL 5

Expert Comment

by:Buginator
ID: 24150115
Try this javascript, place it in your radwindow, within the <head> tags. It will close the radwindow and refresh the parent window (master page)

function CloseAndRefresh()
{
    window.opener.location.href = window.opener.location.href;
    window.close();
}

Also, modify your <body> tag in your radwindow to this::
< body onbeforeunload="CloseAndRefresh()">
0
 
LVL 5

Author Comment

by:chandresh43
ID: 24154902
onbeforeunload not found in asp
body tag
0
 
LVL 5

Accepted Solution

by:
Buginator earned 500 total points
ID: 24156201
It's javascript, not ASP.NET. Here's some info about onbeforeunload. Click #1. Demo.

   <body onbeforeunload="CloseAndRefresh()">


So it would be like this, I've put some extra code for context. Only the script and body tag is important here.



<head runat="server">
    <title></title>
    <script type="text/javascript">
        function CloseAndRefresh() {
            window.opener.location.href = window.opener.location.href;
            window.close();
        }
        </script>
</head>
<body onbeforeunload="CloseAndRefresh()">

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.net Moving Visual Studio 2015 project to 2017 2 71
ComboBox to String Not Working 5 43
Need a quick overview of Selenium testing 2 36
dropdownlist in asp.net vb. 3 25
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question