views:

97

answers:

3

in my master page there is a login status when i click on it the page is redirected to login page.now i want to create login control in the home page itself so that users dont have to visit loginpage again and again..i guess i cant create the login control in the masterpage .it has to be in the default page but then how can i put that control on the top of the page . i have also used login control in masterpage but then my other control ion login page doesnt work properly

A: 

You can add a Login control to your master page by adding something like this to the markup

<asp:Login runat="server" ID="MyLoginControl" />

Or my dragging the Login control onto the master page's designer from the Toolbox.

To hide the login control when the user is logged in, add this code to the master page code-behind:

if (Page.User.Identity.IsAuthenticated)
{
   MyLoginControl.Visible = false;
}
cxfx
let me tell my exact problem.i want 1) login control on home page2) the moment user logins it should become invisible in other pages as that is not the case right now.3) my second login control in login.aspx should also work properly
sumit
Added code example for hiding control when user is logged in.
cxfx
A: 

Ok, let me make the following assumptions.

Currently you have:
- one masterpage
- one default page (of course)
- one login page
- bunch of other pages

You want to have:
- one masterpage (with login control) - one default page (with a main login control)
- no login page
- bunch of other pages

My suggestion:

Option 1
- one masterpage (with login control at the top of page)
- one default page (with a main login control NOT using the materpage)

Option 2
- one masterpage (with login control at the top of page that can be hidden)
- one default page (with a main login control and hiding the masterpage's logincontrol)

Option 3
- one masterpage A (without login control)
- one masterpage B using masterpage A (with login control at the top of page)
- one default page (with a main login control using masterpage B)
- bunch of other pages (using masterpage A)

o.k.w
i think the last option will resolve my purpose,,ok let me try this.thnx for ur reply,i l let u know if i can solve it,,jst give me one hour
sumit
ohh wait if i use another masterpage B using A then is it possible to insert the login control on the top of the page of mastrpage B
sumit
@sumit: yes, masterB = masterA + login-control
o.k.w
but what i have noticed that the login control cant come on the top,,i m a little bit confused when B = A + login control B acts as a simple page inheriting A
sumit
can u send me some posts regarding my problem.
sumit
@sumit: I think I wasn't clear enough. I eman MasterB using MasterA as it's masterpage. Not inheritance. :)
o.k.w
A: 

You can add a Login control to your master page by adding something like this to the markup

<asp:Login runat="server" ID="MyLoginControl" />
bala3569
Why didn't I think of that...
cxfx
how cud i know?
bala3569