Solved

master page in asp.net

Posted on 2009-04-15
14
718 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
  • 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

813 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now