473,853 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

extending MembershipUser, need help!

Hey

ASP.NET 2.0

I'm trying to extend the MembershipUser class, and have encounter a problem:

<< See in the middle of this post for info about why I do this >>
<< See below of this post for the source code of Contact class >>

public class Contact : MembershipUser
{
public Contact(string username)
{
this.UserName = username;
}
}

UserName is readonly so "this.UserN ame = username;" gives an error.

Anybody have a suggestion on how to this???

*************** *************** ***************
Why am I extending MembershipUser class:

I do this because I'm developing a networking website and this code should
return a members friends. This MembershipUserC ollection should display the
friends in a GridView

public static MembershipUserC ollection GetContacts(str ing user)
{
MembershipUserC ollection contacts = null;
List<ContactDet ailrecordset =
SiteProvider.Ne tworking.GetCon tacts(user);
contacts = GetContactListF romContactDetai lsList(recordse t);

return contacts;
}
It's 3 reasons why I do it:
- It is part of N-tier design, this is in the BLL layer. the DAL layer has
sent a collection of objects (each object holding info about a username). An
the task for GetContacts is to convert that list of objects into a
MembershipUserC ollection
- The result of GetContacts will be used in a GridView, which already are
showing data based on MembershipUserC ollection
- It's the best solution I know of... but please, please if you think my
approach sucks then please give me some tips about how you think this should
be done. I love to learn you things and believe many developers have better
approach on this

Any suggestions??

*************** *************** *************** ******
Entire source code of Contact:
using System;
using System.Data;
using System.Web.Secu rity;
using System.Collecti ons.Generic;
using AH.MyNetwork.DA L;
/// <summary>
/// Summary description for Contact
/// </summary>
public class Contact : MembershipUser
{

public Contact(string username)
{
this.UserName = username;
}

public static MembershipUserC ollection GetContacts(str ing user)
{
MembershipUserC ollection contacts = null;
List<ContactDet ailrecordset =
SiteProvider.Ne tworking.GetCon tacts(user);
contacts = GetContactListF romContactDetai lsList(recordse t);

return contacts;
}

private static MembershipUserC ollection
GetContactListF romContactDetai lsList(List<Con tactDetailrecor dset)
{
MembershipUserC ollection contacts = null;
foreach (ContactDetail record in recordset)
contacts.Add(Ge tContactFromCon tactDetails(rec ord));
return contacts;
}

private static Contact GetContactFromC ontactDetails(C ontactDetail
record)
{
if (record == null)
return null;
else
{
return new Contact(record. USERNAME);
}
}

}
Jeff
Mar 28 '07 #1
3 1898
MembershipUser' s constructor allows passing the username (along with
several other values). just call it from your constructor.
-- bruce (sqlwork.com)
Jeff wrote:
Hey

ASP.NET 2.0

I'm trying to extend the MembershipUser class, and have encounter a problem:

<< See in the middle of this post for info about why I do this >>
<< See below of this post for the source code of Contact class >>

public class Contact : MembershipUser
{
public Contact(string username)
{
this.UserName = username;
}
}

UserName is readonly so "this.UserN ame = username;" gives an error.

Anybody have a suggestion on how to this???

*************** *************** ***************
Why am I extending MembershipUser class:

I do this because I'm developing a networking website and this code should
return a members friends. This MembershipUserC ollection should display the
friends in a GridView

public static MembershipUserC ollection GetContacts(str ing user)
{
MembershipUserC ollection contacts = null;
List<ContactDet ailrecordset =
SiteProvider.Ne tworking.GetCon tacts(user);
contacts = GetContactListF romContactDetai lsList(recordse t);

return contacts;
}
It's 3 reasons why I do it:
- It is part of N-tier design, this is in the BLL layer. the DAL layer has
sent a collection of objects (each object holding info about a username). An
the task for GetContacts is to convert that list of objects into a
MembershipUserC ollection
- The result of GetContacts will be used in a GridView, which already are
showing data based on MembershipUserC ollection
- It's the best solution I know of... but please, please if you think my
approach sucks then please give me some tips about how you think this should
be done. I love to learn you things and believe many developers have better
approach on this

Any suggestions??

*************** *************** *************** ******
Entire source code of Contact:
using System;
using System.Data;
using System.Web.Secu rity;
using System.Collecti ons.Generic;
using AH.MyNetwork.DA L;
/// <summary>
/// Summary description for Contact
/// </summary>
public class Contact : MembershipUser
{

public Contact(string username)
{
this.UserName = username;
}

public static MembershipUserC ollection GetContacts(str ing user)
{
MembershipUserC ollection contacts = null;
List<ContactDet ailrecordset =
SiteProvider.Ne tworking.GetCon tacts(user);
contacts = GetContactListF romContactDetai lsList(recordse t);

return contacts;
}

private static MembershipUserC ollection
GetContactListF romContactDetai lsList(List<Con tactDetailrecor dset)
{
MembershipUserC ollection contacts = null;
foreach (ContactDetail record in recordset)
contacts.Add(Ge tContactFromCon tactDetails(rec ord));
return contacts;
}

private static Contact GetContactFromC ontactDetails(C ontactDetail
record)
{
if (record == null)
return null;
else
{
return new Contact(record. USERNAME);
}
}

}
Jeff

Mar 28 '07 #2
yeah, I know. But I have only the username and then I would need to set the
other values to NULL... I could try to do that... maybe somebody here has a
better approach:

In DAL a method returns a collection of objects (each object holding a
user's name - username). The task of BLL is to convert this collection of
objects into a MembershipUserC ollection.... But hey what if the DAL instead
returned a MembershipUserC ollection... I'll try that instead....

Any suggestion/opinions about this??

Jeff

"bruce barker" <no****@nospam. comwrote in message
news:eC******** ********@TK2MSF TNGP02.phx.gbl. ..
MembershipUser' s constructor allows passing the username (along with
several other values). just call it from your constructor.
-- bruce (sqlwork.com)
Jeff wrote:
>Hey

ASP.NET 2.0

I'm trying to extend the MembershipUser class, and have encounter a
problem:

<< See in the middle of this post for info about why I do this >>
<< See below of this post for the source code of Contact class >>

public class Contact : MembershipUser
{
public Contact(string username)
{
this.UserName = username;
}
}

UserName is readonly so "this.UserN ame = username;" gives an error.

Anybody have a suggestion on how to this???

************** *************** *************** *
Why am I extending MembershipUser class:

I do this because I'm developing a networking website and this code
should return a members friends. This MembershipUserC ollection should
display the friends in a GridView

public static MembershipUserC ollection GetContacts(str ing user)
{
MembershipUserC ollection contacts = null;
List<ContactDet ailrecordset =
SiteProvider.N etworking.GetCo ntacts(user);
contacts = GetContactListF romContactDetai lsList(recordse t);

return contacts;
}
It's 3 reasons why I do it:
- It is part of N-tier design, this is in the BLL layer. the DAL layer
has sent a collection of objects (each object holding info about a
username). An the task for GetContacts is to convert that list of objects
into a MembershipUserC ollection
- The result of GetContacts will be used in a GridView, which already are
showing data based on MembershipUserC ollection
- It's the best solution I know of... but please, please if you think my
approach sucks then please give me some tips about how you think this
should be done. I love to learn you things and believe many developers
have better approach on this

Any suggestions??

************** *************** *************** *******
Entire source code of Contact:
using System;
using System.Data;
using System.Web.Secu rity;
using System.Collecti ons.Generic;
using AH.MyNetwork.DA L;
/// <summary>
/// Summary description for Contact
/// </summary>
public class Contact : MembershipUser
{

public Contact(string username)
{
this.UserName = username;
}

public static MembershipUserC ollection GetContacts(str ing user)
{
MembershipUserC ollection contacts = null;
List<ContactDet ailrecordset =
SiteProvider.N etworking.GetCo ntacts(user);
contacts = GetContactListF romContactDetai lsList(recordse t);

return contacts;
}

private static MembershipUserC ollection
GetContactList FromContactDeta ilsList(List<Co ntactDetailreco rdset)
{
MembershipUserC ollection contacts = null;
foreach (ContactDetail record in recordset)
contacts.Add(Ge tContactFromCon tactDetails(rec ord));
return contacts;
}

private static Contact GetContactFromC ontactDetails(C ontactDetail
record)
{
if (record == null)
return null;
else
{
return new Contact(record. USERNAME);
}
}

}
Jeff

Mar 28 '07 #3
This is interesting. I've had it on my mind myself.

I'm reading the way you put it and what does it say to me?
It says "I do this because I'm developing a networking website and this code
should return a members friends" which says to relational model that uses a
"foreign key" used to relate to table(s) of his or her friends. So why not
store a key in the Profile object?

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee. com
URL http://clintongallagher.metromilwaukee.com/


"Jeff" <it************ @hotmail.com.NO SPAMwrote in message
news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
yeah, I know. But I have only the username and then I would need to set
the other values to NULL... I could try to do that... maybe somebody here
has a better approach:

In DAL a method returns a collection of objects (each object holding a
user's name - username). The task of BLL is to convert this collection of
objects into a MembershipUserC ollection.... But hey what if the DAL
instead returned a MembershipUserC ollection... I'll try that instead....

Any suggestion/opinions about this??

Jeff

"bruce barker" <no****@nospam. comwrote in message
news:eC******** ********@TK2MSF TNGP02.phx.gbl. ..
>MembershipUser 's constructor allows passing the username (along with
several other values). just call it from your constructor.
-- bruce (sqlwork.com)
Jeff wrote:
>>Hey

ASP.NET 2.0

I'm trying to extend the MembershipUser class, and have encounter a
problem:

<< See in the middle of this post for info about why I do this >>
<< See below of this post for the source code of Contact class >>

public class Contact : MembershipUser
{
public Contact(string username)
{
this.UserName = username;
}
}

UserName is readonly so "this.UserN ame = username;" gives an error.

Anybody have a suggestion on how to this???

************* *************** *************** **
Why am I extending MembershipUser class:

I do this because I'm developing a networking website and this code
should return a members friends. This MembershipUserC ollection should
display the friends in a GridView

public static MembershipUserC ollection GetContacts(str ing user)
{
MembershipUserC ollection contacts = null;
List<ContactDet ailrecordset =
SiteProvider. Networking.GetC ontacts(user);
contacts = GetContactListF romContactDetai lsList(recordse t);

return contacts;
}
It's 3 reasons why I do it:
- It is part of N-tier design, this is in the BLL layer. the DAL layer
has sent a collection of objects (each object holding info about a
username). An the task for GetContacts is to convert that list of
objects into a MembershipUserC ollection
- The result of GetContacts will be used in a GridView, which already
are showing data based on MembershipUserC ollection
- It's the best solution I know of... but please, please if you think my
approach sucks then please give me some tips about how you think this
should be done. I love to learn you things and believe many developers
have better approach on this

Any suggestions??

************* *************** *************** ********
Entire source code of Contact:
using System;
using System.Data;
using System.Web.Secu rity;
using System.Collecti ons.Generic;
using AH.MyNetwork.DA L;
/// <summary>
/// Summary description for Contact
/// </summary>
public class Contact : MembershipUser
{

public Contact(string username)
{
this.UserName = username;
}

public static MembershipUserC ollection GetContacts(str ing user)
{
MembershipUserC ollection contacts = null;
List<ContactDet ailrecordset =
SiteProvider. Networking.GetC ontacts(user);
contacts = GetContactListF romContactDetai lsList(recordse t);

return contacts;
}

private static MembershipUserC ollection
GetContactLis tFromContactDet ailsList(List<C ontactDetailrec ordset)
{
MembershipUserC ollection contacts = null;
foreach (ContactDetail record in recordset)
contacts.Add(Ge tContactFromCon tactDetails(rec ord));
return contacts;
}

private static Contact GetContactFromC ontactDetails(C ontactDetail
record)
{
if (record == null)
return null;
else
{
return new Contact(record. USERNAME);
}
}

}
Jeff


Mar 29 '07 #4

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

Similar topics

0
1553
by: brett_fyisystems | last post by:
I'm trying to implement an inherited MembershipUser class for a custom MembershipProver for RTM ASP.NET 2.0 I'm using an external assembly that implements these classes. I've signed the assemblies and they compile and sit in the \Bin directory of the ASP.NET website. When I use the ASP.NET Site Configuration manager and hit the Security tab, I get the following...
8
5446
by: Mark Olbert | last post by:
I'm writing a custom MembershipProvider which uses a custom class derived from MembershipUser (basically, the derived class adds a field to the MembershipUser base class). When I try to configure my website using the ASP.NET Configuration tool, and go to the Security page, I get the following error: Could not load type 'OMLMembershipUser' from assembly 'App_Code.olsckwwk, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Yet...
9
1807
by: Mark Olbert | last post by:
I'm reposting this in case it got lost... The ASPNET Configuration tool does not appear to be able to handle derived MembershipUser classes. Even the simplest possible derived class (one which merely wraps MembershipUser itself, duplicates its public constructor but adds no additional methods or properties) causes ASPNET Configuration to blow up. The error message indicates that ASPNET Configuration cannot load the derived Type from the...
0
1148
by: mark d. | last post by:
I've been working through the new features in 2.0 for about a month now, am at the point of trying to apply them to my e-comerce applications. My apps assign a unique custid field in tracking the user throughout their visit. (ie, XYZ20001) I've found a couple of examples on how to customize the membershipprovider object: <a href="http://www.devx.com/asp/Article/29256/1954?pf=true">Writing A Custom Membership Provider for your ASP.NET...
5
3837
by: vbgunz | last post by:
Hello everyone. I own two books. Learning Python and Python in a nutshell. When cross referencing the two books to try and clarify the ideas behind extending methods and delegates, this is where confusion veered it's ugly head :( Learning Python explains on page 324: Class Interface Techniques (21.3.3 in the ebook) the following is an extender method. ''' #################################### '''
3
2234
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 value is displayed. Anyone any idea? Dim user As MembershipUser Dim bruker as string
1
1398
by: Smokey Grindle | last post by:
Im trying to write a custom membership provider but in the GetUser method it returns a MembershipUser, but when i create an object called that it says overload resolution failed... no accessable 'new' accepts this number of arguments... even though my argument list matches up... Dim _user As New System.Web.Security.MembershipUser(Me.ApplicationName, _eUser.UserName, _eUser.UserName, _eUser.ExternalEmailAddress, String.Empty, String.Empty,...
2
1342
by: Cliff | last post by:
Hi, i try to get the emailaddress of an membershipuser: Dim a As MembershipUser Dim em As String em = a.Email.ToString In runtime, i get the error: "Object reference not set to an instance of an object. "
0
1626
by: =?Utf-8?B?TmVhbA==?= | last post by:
I have developed a simple membershipuser class and membershipprovider class. I basically followed the procedures referenced at http://msdn.microsoft.com/en-us/library/44w5aswa.aspx and made it even simpler by inheriting sqlmembershipprovider, and did overrides on only a couple of methods. So far, they seem to work fine when used in code. However, I tried using the web site administration tool to edit a user and received the error below. ...
0
9898
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9748
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11020
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10735
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7907
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Duprť who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7074
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5934
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4549
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.