calvin Posted May 2, 2006 Posted May 2, 2006 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 Quote
Administrators PlausiblyDamp Posted May 2, 2006 Administrators Posted May 2, 2006 http://weblogs.asp.net/scottgu/archive/2005/10/18/427754.aspx might be worth a read (as is most of the blog) as it goes through creating a customised registration process that uses profile to store things. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
calvin Posted May 2, 2006 Author Posted May 2, 2006 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 Quote
calvin Posted May 10, 2006 Author Posted May 10, 2006 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 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.