Unable to retrieve profile info

G

Guest

I'm just starting my first 2.0 site with the new membership features and am
having some trouble with profiles. I have my providers set up and working
fine and profile data is being written to the database. However, I can't
retrieve any of the stored profile values on my site. I set up the provider
and everything just like it is explained in the various MSDN articles, but
still nothing.

Any thoughts?
 
C

Chris Fulstow

Hi Ashley,

How are you writing profile data to the database, is it through the
Page.Profile object? When you try to retrieve you profile data, do the
profile fields you configured in web.config appear under Intellisense?

Chris
 
G

Guest

I'm writing the values through a click handler like this:

profile.DisplayName = txtDisplayName.Text

The data is making it to the database just fine, but doesn't come back when
I make a call to profile.DisplayName

DisplayName does show up under Intellisense when I type in "profile".
 
T

tdavisjr

Isn't it Profile.DisplayName (with a capital "P")

If your using VB then I don't think it makes much of a difference; but
this is the only thing I can think of.
 
G

Guest

I just made a simple form with a textbox and a button. When the button is
clicked it fires the click handler and apparently does the update because the
database is correct.
 
C

Chris Fulstow

Do you get IntelliSense for your profile properties when you set the
value, or do you need to type it manually? Can you see the profile
data in the database, or is it just the profile table structure?
 
G

Guest

Yes, I get the Intellisense for the profile entry I created. The profile
data does get written to the database. Everything is happening the way it's
supposed to except for when I actually try and display the profile data
somewhere.

So, on the form I created to change the Display name I have this in my
Page_Load:

If Not Page.IsPostBack then
txtDisplayName.Text = profile.DisplayName
End If

And the click handler has only this:

profile.DisplayName = txtDisplayName.Text

The txtDisplayName textbox never has the existing profile in it on page
load, nor do any of the other pages where I attempt to call
profile.DisplayName.
 
C

Chris Fulstow

All looks ok, what have you got in the <profile> section of your
web.config? Are you using some sort of authentication or is it
anonymous users?
 
G

Guest

Anonymous users can't even reach the form for setting a DisplayName.

I'm at work right now and don't have access to my Web.config file directly,
so I'll do my best to reproduce the profile section from memory:

<profile enabled="true" providerName="sqlProfileProvider">
<providers>
<clear/>
<add name="sqlProfileProvider" connectionString="TNSDB" />
</providers>
<properties>
<add name="DisplayName" type="System.String" />
</properties>
</profile>
 
C

Chris Fulstow

It seems a bit weird that IntelliSense shows your profile properties in
the button click handler, but not in the page load handler? Both
methods should be referencing the same Page object with the same
properties.

Can you read the profile property in the button click handler, as well
as write it?
 
G

Guest

Oh, it gets weirder...

I put in a msgbox to tell me what the value of profile.DisplayName is right
before I do profile.DisplayName = txtDisplayName.Text and it shows me the
right value.

I also set up a label on the page that gets it's value from the
profile.DisplayName as well during the page_load. Same deal here as with the
textbox though, in that the value isn't there until after the submit button
is clicked.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top