My application uses .net membership, I added some new properties but on calling Profile.save() it still save the old values, What i am doing wrong?
Code:
<roleManager defaultProvider="AspNetSqlRoleProvider" enabled="true">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" connectionStringName="gmembers" applicationName="/MobileToday" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</providers>
</roleManager>
<profile enabled="true" defaultProvider="gMembersProfileSqlProvider">
<providers>
<clear/>
<remove name="gMembersProfileSqlProvider"/>
<add name="gMembersProfileSqlProvider" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="gmembers" applicationName="/MobileToday"/>
</providers>
<!-- Define the properties for Profile... -->
<properties>
<add name="Title" allowAnonymous="true"/>
<add name="FirstName" allowAnonymous="true"/>
<add name="LastName" allowAnonymous="true"/>
<add name="Gender" type="string"/>
<add name="Company" allowAnonymous="true"/>
<add name="Address" allowAnonymous="true"/>
<add name="Avatar" allowAnonymous="true"/>
<add name="Newsletter" allowAnonymous="true"/>
<add name="AcceptMailUs" allowAnonymous="true"/>
<add name="AcceptMailOthers" allowAnonymous="true"/>
<add name="imageORavatar" allowAnonymous="true"/>
<add name="Mobile" allowAnonymous ="true"/>
<add name ="JobTitle" allowAnonymous ="true" />
<add name ="StoreNumber" allowAnonymous ="true"/>
<add name="BusinessAddress" allowAnonymous ="true"/>
<add name="BusinessPostcode" allowAnonymous ="true"/>
<add name="BusinessTown" allowAnonymous ="true"/>
<add name="BusinessPhone" allowAnonymous ="true"/>
<add name="CompanyTypeID" allowAnonymous ="true"/>
<add name="CompanyTypeName" allowAnonymous ="true"/>
<add name="CompanyNameID" allowAnonymous ="true"/>
<add name="JobFunctionID" allowAnonymous ="true"/>
<add name="JobFunctionName" allowAnonymous ="true"/>
</properties>
</profile>
<anonymousIdentification enabled="true" cookieName=".ASPXANONYMOUS" cookieTimeout="43200" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" cookieless="UseCookies"/>
<authentication mode="Forms">
<forms name=".TestAuth" loginUrl="login.aspx" defaultUrl="~/__admin/pages/viewlist.aspx"></forms>
</authentication>
<authorization>
<!--<allow roles="Admin" />
<allow roles="Editor" />
<deny users="?" />
<deny users="*" />-->
</authorization>
<membership defaultProvider="MyAspNetSqlMembershipProvider">
<providers>
<clear/>
<add name="MyAspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="gmembers" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="20" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/MobileToday"/>
</providers>
</membership>
Code:
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
ReturnUrl = Trim(Request.QueryString("ReturnUrl"))
' Try
'If Page.IsValid Then
Dim newsletter As Integer = If((chkNewsletter.Checked), 1, 0)
Dim acceptmailus As Integer = If((chkAcceptMailUs.Checked), 1, 0)
Dim acceptmailothers As Integer = If((chkAcceptMailOthers.Checked), 1, 0)
Dim imageORavatar As String
Dim utl As New Utilities()
'create user
'profile add
Try
Membership.CreateUser(Session("RegisterUsername").ToString(), utl.Decrypt1(Session("RegisterPassword").ToString()), Session("RegisterEmail").ToString())
Catch ex As MembershipCreateUserException
Response.Redirect("problem.aspx")
'Throw ex
End Try
Profile.Title = txtTitle.Text
Profile.FirstName = txtFirstName.Text
Profile.LastName = txtLastName.Text
If DDCompanyName.SelectedValue.ToString = "999" Then
Profile.Company = txtCompanyNameOther.Text
Else
Profile.Company = DDCompanyName.SelectedItem.Text
End If
Profile.Address = txtAddress.Text
Profile.Avatar = "" 'thumbnailFileName1
Profile.Newsletter = chkNewsletter.Checked.ToString()
Profile.AcceptMailUs = chkAcceptMailUs.Checked.ToString()
Profile.AcceptMailOthers = chkAcceptMailOthers.Checked.ToString()
Profile.imageORavatar = 2 'imageORavatar // Set 2 For Default Avatar
Profile.JobTitle = txtJobTitle.Text
Profile.StoreNumber = txtStoreNumber.Text
Profile.BusinessAddress = txtBusinessAddress.Text
Profile.BusinessPostcode = txtBusinessPostcode.Text
Profile.BusinessTown = txtBusinessTown.Text
Profile.BusinessPhone = txtBusinessPhone.Text
Profile.CompanyNameID = DDCompanyName.SelectedValue
Profile.CompanyTypeID = DDCompanyType.SelectedValue
If DDCompanyType.SelectedValue.ToString = "999" Then
Profile.CompanyTypeName = txtCompanyNameOther.Text
Else
Profile.CompanyTypeName = DDCompanyType.SelectedItem.Text
End If
Profile.JobFunctionID = DDJobFunction.SelectedValue
If DDJobFunction.SelectedValue.ToString = "999" Then
Profile.JobFunctionName = txtJobFunctionOther.Text
Else
Profile.JobFunctionName = DDJobFunction.SelectedItem.Text
End If
Profile.Save()
FormsAuthentication.SetAuthCookie(Session("RegisterUsername").ToString(), False)
' End If
'Catch ex As Exception
'End Try
If ReturnUrl = "" Then
Response.Redirect("success.aspx")
Else
Response.Redirect("success.aspx?ReturnUrl=" & HttpUtility.UrlEncode(ReturnUrl))
End If
End Sub