Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old January 15th, 2009, 08:33 AM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default How to Change the page content Per User

Hi there i am developing an application for a coompany with 20 users and they have their user name /password in order to log in. The users need to have spesific Controls displayed in the page based on whaat i am going to assign them.(something similar in the Wrox United/FunClub.aspx in the button save).
From the admin Page i need to Select a User and asign him/her values/controles to be displayd after they have loged in.

i was thinking about loginview controll ? and i need to bind data from a sql Sqerver 2005
__________________
bx
  #2 (permalink)  
Old January 15th, 2009, 11:43 AM
Friend of Wrox
Points: 2,101, Level: 18
Points: 2,101, Level: 18 Points: 2,101, Level: 18 Points: 2,101, Level: 18
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Hi,

I don't have any experience with the loginview control but I found some good info and some source code for implementation.

http://quickstarts.asp.net/QuickStar...spx#createuser

I have an application where I created the login and authorization with roles, menu groups and page by page features. The authorization is stored in Session variables.
  #3 (permalink)  
Old January 15th, 2009, 01:29 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Code:
<asp:LoginView ID="LoginView1" runat="server">
   <RoleGroups>

      <asp:RoleGroup Roles="Manager">
         <ContentTemplate>
            <p>Hi there! You are a Manager!</p>            
         </ContentTemplate>
      </asp:RoleGroup>

      <asp:RoleGroup Roles="Employee">
         <ContentTemplate>
            <p>
               Hi there! You are an Employee!</p>            
         </ContentTemplate>
      </asp:RoleGroup>
   </RoleGroups>

   <LoggedInTemplate>
      <p>
         Hi there! You belong to no roles.</p>
   </LoggedInTemplate>

</asp:LoginView>
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
The Following User Says Thank You to Lee Dumond For This Useful Post:
Old Pedant (January 15th, 2009)
  #4 (permalink)  
Old January 15th, 2009, 05:58 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Man, if that were any simpler you could let it write itself. Never used LoginView before. Because I "grew up" with roll-your-own authentication. Now you are making me rethink some pages. Thanks!
  #5 (permalink)  
Old January 15th, 2009, 06:18 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

You're welcome!
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
  #6 (permalink)  
Old January 15th, 2009, 09:14 PM
Friend of Wrox
Points: 2,101, Level: 18
Points: 2,101, Level: 18 Points: 2,101, Level: 18 Points: 2,101, Level: 18
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Hi Lee,

Thanks for the post. Where does all the role and user/role info get stored? I feel like this might be a dumb question, but don't you still have store this info in a database somehow?

Thanks,
Richard
  #7 (permalink)  
Old January 15th, 2009, 10:52 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Try this link:
http://aspnet.4guysfromrolla.com/articles/121405-1.aspx

Have known about those pages since they first appeared. Now I may actually go read them.
  #8 (permalink)  
Old January 15th, 2009, 11:17 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts
Default

Quote:
Originally Posted by rstelma View Post
Hi Lee,

Thanks for the post. Where does all the role and user/role info get stored? I feel like this might be a dumb question, but don't you still have store this info in a database somehow?

Thanks,
Richard
Yeah, you have to set this all up in a database, and there are membership and role providers you can set up in web.config that will let you work with the data. Fortunately, ASP.NET comes with tools that assist in setting up the dB schema and sprocs automatically.

Scott Mitchell's articles linked above will help, and there is also a whole series of videos at http://asp.net that demonstrate how memberships and roles work.
__________________
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

Code:
if (this.PostHelpedYou)
{
   ClickThanksButton(); 
}
  #9 (permalink)  
Old January 16th, 2009, 12:51 PM
Friend of Wrox
Points: 2,101, Level: 18
Points: 2,101, Level: 18 Points: 2,101, Level: 18 Points: 2,101, Level: 18
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2003
Location: , , .
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Thank you for the replies.

This sounds great. Now, if there's only a way to keep track of what roles get what permission on which pages.

Sounds like it's time for an old dog learn some new tricks.

Thanks,
Richard
  #10 (permalink)  
Old January 16th, 2009, 02:40 PM
bex bex is offline
Friend of Wrox
 
Join Date: Aug 2008
Location: london, , United Kingdom.
Posts: 154
Thanks: 7
Thanked 1 Time in 1 Post
Default

Ok what about this:
on the log in page i have a login name controll that shows the name of the user loged in, now i need to check if login name = test then
lblconntrol1= a row from the database table that is = to the user name.
on the table i have 2 columns 1=user, 2= template
can you see what i am trying to do ?
__________________
bx
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I log out, not leave the page & change content edurazee ASP.NET 2.0 Basics 0 July 22nd, 2008 10:25 PM
How to change content of setup.exe bijgupt Other Programming Languages 1 July 22nd, 2008 06:24 AM
change content of textarea from select darkhalf Javascript 1 April 26th, 2007 06:03 AM
How to change the value of content of meta object Abdul Hameed HTML Code Clinic 2 August 12th, 2004 04:40 AM
How to change the value of CONTENT of META object Abdul Hameed Javascript 1 August 11th, 2004 10:02 AM



All times are GMT -4. The time now is 03:39 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.