473,563 Members | 2,831 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 1883
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
1540
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...
8
5419
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'...
9
1793
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...
0
1130
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...
5
3819
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...
3
2214
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
1384
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...
2
1323
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
1612
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....
0
7583
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...
0
7885
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. ...
0
8106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7948
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5213
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...
0
3642
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2082
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
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
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...

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.