Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics 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 Search this Thread Display Modes
  #1 (permalink)  
Old March 20th, 2009, 12:19 PM
Authorized User
 
Join Date: Jan 2009
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default Members adding information

I have a members section on my website that includes a city contact page where registered users can search for a city and find users who have lived there. The question that I can't seem to answer is how do create a form that allows the users to enter and edit their own information when they are logged in. I have a repeater which shows all of the city contacts, but I have been unable to tailor a details view that will insert based on the member who is signed in. Any ideas would be appreciated as I have been stuck on this for a while.
  #2 (permalink)  
Old March 20th, 2009, 01:43 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

I think the first question is: where do you store the data. City is not a standard property of the MembershipUser class so you must be storing it elsewhere. Maybe in Profile or maybe in a custom solution?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #3 (permalink)  
Old March 20th, 2009, 03:14 PM
Authorized User
 
Join Date: Jan 2009
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I set up a profile which includes the member name and the countries that they have lived in. Idealy what I would like to do is have them able to enter their name, email address, and review of the city if they selected the country in their profile. But from what I read in your asp.net 3.5 book, the profile is stored in a cookie and not in a database. Is that correct? I have a separate table for the reviews city_review. I just keep going in circles with the logic.
  #4 (permalink)  
Old March 21st, 2009, 05:33 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

No, the profile is NOT stored in a cookie. What page / section gave you that impression? Profile data is stored in the database, in aspnet_Profile to be exact. When (anonymous) users visit the site, their ID may be stored in a cookie, but the actual data is stored in the database.

The aspnet_Profile is not the perfect table as it's hard to impossible to query data from it directly. E.g. you can't create your own SQL statement to filter all users from a specific city. If that's what you want, look at the Table and Stored Procedure Profile providers that replace the standard Profile engine that stored data in aspnet_Profile with one that allows you to determine where to store the data: http://www.asp.net/downloads/sandbox...vider-samples/

Quote:
and review of the city if they selected the country in their profile
A review doesn't really sound like Profile data, does it? ANd as such shouldn't be stored in the user's Profile. You're better of storing the reviews in a separate table and store the user's ID in that table as well so you can see who wrote the review.

Quote:
I have a separate table for the reviews city_review
So what does this table contain? And what do you store in profile? I am a little confused as to what you're trying to accomplish, how your database looks, what you're storing where and so on. Can you elaborate on all that, describing things as clear as possible?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #5 (permalink)  
Old March 21st, 2009, 06:34 AM
Authorized User
 
Join Date: Jan 2009
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I reread the section on the Profile and now understand it more clearly.

Originally, I set up the page as such:

<asp:DropDownListID="DropDownList1"runat="server"AutoPostBack="True"DataSourceID="SqlDataSource1"DataTextField="Country"DataValueField="Id"AppendDataBoundItems="true"style="text-align: center">
<asp:ListItemValue="">Please select a country</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSourceID="SqlDataSource1"runat="server"ConnectionString="<%$ ConnectionStrings:WebsiteConnectionString1 %>"SelectCommand="SELECT [Country], [Id] FROM [Countries] ORDER BY [Country]">
</asp:SqlDataSource>
<asp:DropDownListID="DropDownList2"runat="server"DataSourceID="SqlDataSource2"DataTextField="Name"DataValueField="Id"AppendDataBoundItems="true"AutoPostBack="True"Visible="False">
</asp:DropDownList>
<asp:SqlDataSourceID="SqlDataSource2"runat="server"ConnectionString="<%$ ConnectionStrings:WebsiteConnectionString1 %>"SelectCommand="SELECT [Name], [CountryId], [Id] FROM [Cities] WHERE ([CountryId] = @CountryId) ORDER BY [Name]">
<SelectParameters>
<asp:ControlParameterControlID="DropDownList1"Name="CountryId"PropertyName="SelectedValue"Type="Int32"/>
</SelectParameters>
</asp:SqlDataSource></div>
<asp:RepeaterID="Repeater1"runat="server">
<ItemTemplate>
<pclass="Contacts">
<%# Eval("MemberName") %> <br/>
<%# Eval("Email") %> <br/>
<%# Eval("Summary") %>
</p></ItemTemplate>
</asp:Repeater>

The user selects the country and the city list is populated. From the city they select, I have a repeater that presents all of the information that is in the Review table [MemberId] [CityId] [Summary] table by joining it with the Member table [MemberName] [Email] on [MemberId]. However, these tables are located in a database separate from the aspnetdb.

All I want to do is add the ability for a logged in user to add themselves as a contact and be able to edit/delete their information if they already have added themselves as contact but only when logged in as a regisetered user.
  #6 (permalink)  
Old March 21st, 2009, 09:30 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You can always access the currently logged in user like this:

Dim myUser As MembershipUser = Membership.GetUser()

When myUser is notNothing, you can access the ProviderUserKey property which is a Guid:

Dim userId As Guid = CType(myUYser.providerUserKey, Guid)

Alternatively, Context.User.Identity.Name to get the user's name. In both cases, you can use the name / ID to relate the user to your own records.

For more ideas on this: How to use login user name in where clause?

storing the login name in my personal database

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #7 (permalink)  
Old March 22nd, 2009, 10:19 AM
Authorized User
 
Join Date: Jan 2009
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

To make it more clear, this is exactlty what I want to happen:

1. User registers for the site.
2. User fills in profile information which contains which countries they have lived in
3. User goes to the contacts page to see what cities have contacts.
4. If they want to become a contact, they can fill out a form: Name, Email, and Review. I would like the name and the email address to be already filled in based on the user and the only thing that I would like them to fill out is the Review.
5. When they submit the review, it is store in the database as not having been approved and an email is sent to the administrator notifying them of a new review awaiting approval.
6. Once the review is approved, the user can go back and edit and or delete only their review.

I already have sets 1 - 3 completed. I am struggling with 4 - 6. What is the best way to accomplish these tasks?

Last edited by areed24; March 22nd, 2009 at 10:40 AM..
  #8 (permalink)  
Old March 22nd, 2009, 10:39 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

It doesn't really matter. You can combine them in one database, or keep them separated. I prefer to have everything in a single database named after my project. I then use the aspnet_regsql tool to prepare my database for the ASP.NET provider services.

Not sure what you're asking about countries and cities....'


Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #9 (permalink)  
Old March 23rd, 2009, 03:28 PM
Authorized User
 
Join Date: Jan 2009
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is there a way to access the UserId from the Profile and not the UserName? When a logged in user fills out the form to become a city contact, I would like their name and email address to be automatically filled in based on the aspnetMembership table.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Using Fore_color in calculated members preetham SQL Server 2005 1 November 23rd, 2007 07:33 AM
Members list happygv Forum and Wrox.com Feedback 9 April 10th, 2007 11:33 AM
Listing members quiksilverhg Excel VBA 1 October 6th, 2005 05:09 AM
Best way to secure a members section tdaustin Classic ASP Basics 2 May 18th, 2004 07:30 AM
Thanks For P2P and thier members. Mike_D Beginning VB 6 0 September 5th, 2003 08:00 PM



All times are GMT -4. The time now is 09:29 AM.


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