I am creating a similar appln as the "beerhouse" project. I have the user control "userprofile". I dont have any "newsletter" in my application but the "username" is stored in the "newsletter" i need a alternative to get the username. here is what i have
tried
userprofile.aspx.cs
private string _userName = "";
public string UserName
{
get { return _userName; }
set { _userName = value; }
}
In the aspx page when the user is created i write the following code.
Ganesh@Nilgr...
Contributor
6074 Points
2354 Posts
getting the userName
Sep 26, 2008 05:41 AM|LINK
I am creating a similar appln as the "beerhouse" project. I have the user control "userprofile". I dont have any "newsletter" in my application but the "username" is stored in the "newsletter" i need a alternative to get the username. here is what i have tried
userprofile.aspx.cs
private string _userName = ""; public string UserName { get { return _userName; } set { _userName = value; } }In the aspx page when the user is created i write the following code.
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e){
UserControls_userprofile objuser = new UserControls_userprofile();objuser.UserName = CreateUserWizard1.UserName; ;
Roles.AddUserToRole(CreateUserWizard1.UserName, "Posters");}
now when i keep the a breakpint on "objuser.UserName" it has got the value but below is the problem
protected override object SaveControlState(){
object[] ctlState = new object[2];ctlState[0] =
base.SaveControlState(); ctlState[1] = this.UserName;return ctlState;}
in "cllstate[1]" it is not having the "username" . i know the above function is called many times and every time the call is made it is empty.
Any ideas ??
Please Mark As Answer If my reply helped you.
pvkirankumar
Member
427 Points
95 Posts
Re: getting the userName
Sep 26, 2008 07:01 AM|LINK
hi,
You need to store objuser.UserName into your UserName first
and then do ctlState[1] = this.UserName
Regards
Kiran Kumar PV
Kiran Kumar
An ounce of practice is worth more than tons of preaching
Ganesh@Nilgr...
Contributor
6074 Points
2354 Posts
Re: getting the userName
Sep 26, 2008 08:34 AM|LINK
I hope that is wht iam doing . if u look my code u can undertsand.
Please Mark As Answer If my reply helped you.
jimibt
Member
724 Points
185 Posts
Re: getting the userName
Sep 26, 2008 09:52 AM|LINK
Ganesh,
try changing:
userprofile.aspx.cs
private string _userName = ""; public string UserName { get { return _userName; } set { _userName = value; } }to:
userprofile.aspx.cs
notice the change of _userName to being a 'static' member.jimi
jimi
Ganesh@Nilgr...
Contributor
6074 Points
2354 Posts
Re: getting the userName
Sep 26, 2008 10:59 AM|LINK
i was thinking of "static" keyword but did not attempt. Thanks it worked. [cool]
Please Mark As Answer If my reply helped you.
jimibt
Member
724 Points
185 Posts
Re: getting the userName
Sep 26, 2008 11:37 AM|LINK
no worries - this kinda thing occassionally get's overlooked and can cause hours of debug frustration. [:S] glad it worked for you.
jimi
jimi