Solved

master page in asp.net

Posted on 2009-04-15
14
716 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
 
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

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…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

19 Experts available now in Live!

Get 1:1 Help Now