Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

master page in asp.net

Posted on 2009-04-15
14
Medium Priority
?
724 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
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!

 
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 1500 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

664 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