I have a login page and to it a master page which contains menu bar and footer bar ..so I want to prevent the user from accessing master page content until and unless the user is logged in ...so please if anyone gives a solution for this i wouldbe thankfull
to you.
I have a login page and to it a master page which contains menu bar and footer bar
1. You can simply hide the footer and menu of the master page at the login page
2. You can maintain a seperate master page for your login page (Easiest way)
3. Do not use a master page at all in your login page. If you are going to prevent the users from accessing it, what's the point of showing them at the login page? If you are going to hide the controls, then there is no point of having a master page. :)
but my requirement is to make it visible but not to access it until n unless the user logins
Hi,
Are you using asp.net membership to implement the authentication? If so, you can check
if(!Request.IsAuthenticated)
{
//Disable all buttons in master page.
}
Check the condition on Page_Load event of the master page. If you aren't using asp.net membership, check whether user is logged in or not according to your implementation of the login and if the user is not logged in, disable all the controls in footer and
menu.
niranjan479
Member
34 Points
75 Posts
Master Page and Login Page
Jun 09, 2012 05:15 AM|LINK
Hello,
I have a login page and to it a master page which contains menu bar and footer bar ..so I want to prevent the user from accessing master page content until and unless the user is logged in ...so please if anyone gives a solution for this i wouldbe thankfull to you.
Ruchira
All-Star
43010 Points
7027 Posts
MVP
Re: Master Page and Login Page
Jun 09, 2012 11:28 AM|LINK
Hello,
1. You can simply hide the footer and menu of the master page at the login page
2. You can maintain a seperate master page for your login page (Easiest way)
3. Do not use a master page at all in your login page. If you are going to prevent the users from accessing it, what's the point of showing them at the login page? If you are going to hide the controls, then there is no point of having a master page. :)
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.sanjayverma_...
Participant
1468 Points
346 Posts
Re: Master Page and Login Page
Jun 09, 2012 11:49 AM|LINK
Hi ,
you can do this by Making the like Enable false and when user get login then you make them enable true at .cs page through coding.
hope this help you
sanjayverma_...
Participant
1468 Points
346 Posts
Re: Master Page and Login Page
Jun 09, 2012 12:14 PM|LINK
Hi
it will be like this
protected void btn1_Click(object sender, EventArgs e) { Link1.Enabled = true; } <div> <asp:LinkButton ID="Link1" runat="server" Enabled="false" PostBackUrl="~/Default.aspx" Text="Enable"></asp:LinkButton><br /> <asp:Button ID="btn1" runat="server" Text="enable true" onclick="btn1_Click" /> </div>In this way you and enable and disable your controls while login and logout button click.
Hope this will help you
niranjan479
Member
34 Points
75 Posts
Re: Master Page and Login Page
Jun 09, 2012 12:53 PM|LINK
ya i thought of hiding the master page but my requirement is to make it visible but not to access it until n unless the user logins..
Ruchira
All-Star
43010 Points
7027 Posts
MVP
Re: Master Page and Login Page
Jun 09, 2012 12:58 PM|LINK
Hi,
Are you using asp.net membership to implement the authentication? If so, you can check
if(!Request.IsAuthenticated) { //Disable all buttons in master page. }Check the condition on Page_Load event of the master page. If you aren't using asp.net membership, check whether user is logged in or not according to your implementation of the login and if the user is not logged in, disable all the controls in footer and menu.
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.niranjan479
Member
34 Points
75 Posts
Re: Master Page and Login Page
Jun 09, 2012 01:00 PM|LINK
Thanks sanjay that was very much helpful...