Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 3rd, 2010, 06:21 AM
Authorized User
Points: 395, Level: 6
Points: 395, Level: 6 Points: 395, Level: 6 Points: 395, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2007
Location: London, , United Kingdom.
Posts: 73
Thanks: 4
Thanked 0 Times in 0 Posts
Default Adding new properties in .net membership

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
__________________
Cheers
Sheraz
Reply With Quote
  #2 (permalink)  
Old December 27th, 2010, 11:46 AM
Authorized User
Points: 97, Level: 1
Points: 97, Level: 1 Points: 97, Level: 1 Points: 97, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2010
Posts: 21
Thanks: 4
Thanked 1 Time in 1 Post
Default

What is your resource for this code?
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
.net membership issue dotnet_user ASP.NET 3.5 Basics 9 January 24th, 2012 11:45 AM
Question about Asp.net Membership chobo2 ASP.NET 3.5 Basics 3 April 2nd, 2009 04:02 PM
Help with ASP.NET Membership VerbatimBOT SQL Server 2000 6 May 2nd, 2007 01:58 PM
Roles and membership asp.net 2 zeeshannasir ASP.NET 2.0 Basics 2 September 15th, 2006 07:24 AM
Adding Properties to Buttons in a GridView Aaron Edwards ASP.NET 2.0 Basics 3 July 23rd, 2006 01:48 PM



All times are GMT -4. The time now is 05:13 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.