473,324 Members | 2,511 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

update more than only the email with asp.net membership

Hi all,

I am currently developing in asp.net 2.0 and I was at first impressed
with the numerous login and user controls they provided to ease the
task of managing users.

But I am starting to think it's an hassle for certain tasks...here's my
problem :

I have created some users and successfully log them with the supplied
controls. However, I have hard times with the 'user managment' screen
(for the admin). On one page, I list all the users available in a
Gridview. Up to there, everything works, great. However, I need to
update the users information and I've tried the method suggested here
(http://asp.net/QuickStart/util/srcvi...ty/Update.src),
adapted to a gridview (with the RowUpdating event).

But with the given method, I can only update the email!! what the
&*$%......I can't change the Username nor the IsLockedOut values,
because they are 'ReadOnly' properties. What does that mean? That I
can't change them at all? How is the admin going to disable any users?

I'd appreciate if someone can point me some resource that explain how
to update user properties like username or locked status. This
membership system is getting me mad.

Thanks! :)

ibiza

Mar 2 '06 #1
3 1316
Hello ibiza,

I'm not sure exactly what the problem is with your code but I noticed in the
source from the Quickstart, that many of the bound items are marked as
ReadOnly. If you change that property, then you should be able to change
those fields (you probably already know this). My understanding is that if
you go with the default membership data schema, everything is keyed off the
username (an aspect that I disagree with. I feel that everything should be
keyed off the email. But that's another story). I would assume that means you
probably don't want to be mucking around with the username (they should
probably be unique) and that's why they made the quickstart tutorial the way
they did.

--
brians
http://www.limbertech.com
"ibiza" wrote:
Hi all,

I am currently developing in asp.net 2.0 and I was at first impressed
with the numerous login and user controls they provided to ease the
task of managing users.

But I am starting to think it's an hassle for certain tasks...here's my
problem :

I have created some users and successfully log them with the supplied
controls. However, I have hard times with the 'user managment' screen
(for the admin). On one page, I list all the users available in a
Gridview. Up to there, everything works, great. However, I need to
update the users information and I've tried the method suggested here
(http://asp.net/QuickStart/util/srcvi...ty/Update.src),
adapted to a gridview (with the RowUpdating event).

But with the given method, I can only update the email!! what the
&*$%......I can't change the Username nor the IsLockedOut values,
because they are 'ReadOnly' properties. What does that mean? That I
can't change them at all? How is the admin going to disable any users?

I'd appreciate if someone can point me some resource that explain how
to update user properties like username or locked status. This
membership system is getting me mad.

Thanks! :)

ibiza

Mar 2 '06 #2
Hi brians, thank you very much for your reply.

They made the bound items read only so the user cannot change them.
However, being able to change them does not mean being able to update
them. The real update is done here :

Sub DetailsView1_ItemUpdating(ByVal sender As Object, ByVal e as
DetailsViewUpdateEventArgs)
'Need to handle the update manually because MembershipUser does
not have a
'parameterless constructor
Dim memUser as MembershipUser = Membership.GetUser()

memUser.Email = CStr(e.NewValues(0))
memUser.Comment = CStr(e.NewValues(1))

Try
Membership.UpdateUser(memUser)

e.Cancel = true
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
Catch ex as Exception
Response.Write("<div>The following error occurred:<font
color='red'> " + ex.Message + "</font></div>")

e.Cancel = true
End Try
End Sub

The fact is, if you add for example :

"memUser.IsLockedOut = True", it would throw an exception, as the
property IsLockedOut from MembershipUser is read-only. So they only
made the bound controls readonly because even if the user had the
chance to change the data in textboxes, it could not be updated
programatically because the MembershipUser object would not allow it.

I can live, if I have to, with not being able to change the username,
but gosh, I really need to lock/unlock users.

Mar 2 '06 #3
Hi ibiza,

Just from a quick glance at the stored procedure
aspnet_Membership_UpdateUser would lead me to believe that you don't want to
be unlocking the user with the UpdateUser() method. But there is an
aspnet_Membership_UnlockUser stored procedure which I would assume resolves
to the MembershipUser.UnlockUser() method. You can probably use it to unlock
the user.

--
brians
http://www.limbertech.com

Mar 2 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

114
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
1
by: dmiller23462 | last post by:
Does anyone see anything OUTRIGHT that I can fix on this....I'm a virgin ASP'er and I'm trying to produce an email from a form submission button....This is just my little "template" for future use...
2
by: lulupuce | last post by:
Hi! I have a problem with a small app. I have a membership table and a payment table, they work ok together but when I create a new member I want the app to create a new record in the payments as...
1
by: Trevor | last post by:
Hi AllI have a membership database that has a member form with a membership details subform on it. The sub form has Date & Membership Level fieldsI need to display the Membership Level from the...
3
by: ibiza | last post by:
Hi all, I am currently developing in asp.net 2.0 and I was at first impressed with the numerous login and user controls they provided to ease the task of managing users. But I am starting to...
0
by: melledge | last post by:
XTech 2006 Updates -Keynote Update - Barcamp Amsterdam II XTech 2006 - 16-19 May - Hotel Grand Krasnapolsky - Amsterdam, The Netherlands Mozilla keynote added to agenda - Brendan Eich, CTO,...
2
by: TJ | last post by:
Hi All, I am having some trouble. I have created a database via the new database option inside VWD2005. Then and table or two. I have been able to perform INSERT and SELECT operations on...
3
by: Linn | last post by:
Hi, I am trying to update the e-mail for å user (as an admin), but the new e-mail address is not saved. The msgbox gives met he correct email, but when I reload my data in the gridview, the old...
2
by: Andy B | last post by:
I have a database with asp.net membership inside it. How would I use it for 2 or more web applications at the same time?
8
by: nargis2009 | last post by:
Hi, I have been encountering problems with my web page which is supposed to send email, and wondered if anybody can help find error. Initially I had all codes in one page and on click of...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.