Can't get the Profile value

calvin

Regular
Joined
Nov 6, 2003
Messages
71
Hi,

I create a asp.net 2.0 website and a lot of page include a login page. I convert the login control to template because i want to add a dropdownlist which poses some value which is needed like schoolID. The login page is work fine, but what i need is when user authenticated, I want to store some value to the profile. Like SchoolID, Role, and UserID. So I add the code below to the login page.

Login.aspx.vb
Protected Sub LoginButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If User.Identity.IsAuthenticated Then
If User.IsInRole("admin") Then
Dim ddlSchoolID As DropDownList = Me.LoginView1.FindControl("ddlSchoolID")
Dim UserName As TextBox = Me.LoginView1.FindControl("UserName")
Profile.SchoolID = ddlSchoolID.SelectedValue
Profile.UserID = UserName.Text
Profile.Role = "admin"
End If
End If
End Sub

Web.config
<anonymousIdentification enabled="true"/>
<profile>
<properties>
<add name="SchoolID" defaultValue="ABC01" allowAnonymous="true"/>
<add name="UserID" defaultValue="A0001" allowAnonymous="true"/>
<add name="Role" defaultValue="user" allowAnonymous="true"/>
</properties>
</profile>

Because I need to use the Profile value when user logon (like use the value to create dynamic menu and so on. All the page is running, just cannot get the value from profile only. It always get the default value in web.config. I believe it must be something wrong in the login button event.

Hope someone can help on this. Thank you.

*Is anyone have some reference regarding popup calendar in gridview in editmode

Calvin
 
Can't get object control in the template

Get this error "Object reference not set to an instance of an object." to the object in login template(SchoolID dropdownlist, textbox).

Calvin
 
Problem Solved.

Solution: when you click your button you're not yet authenticated. You should try with the event loggedin :

Protected Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles Login1.LoggedIn

Profile.xxx = xxx
Profile.Save()


End Sub
 
Back
Top