Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Personalization in .NET

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 51
    Comment on it

    It is based on user profile. It will define the details associated with the user for saving it into the database.

    User profile include the personal details of the user, like its date of birth,address, birthday etc.

    This information is stored in Web.Config.

    1. <configuration>
    2. <system.web>
    3.  
    4. <profile>
    5. <properties>
    6. <add name="Name" type ="String"/>
    7. <add name="Birthday" type ="System.DateTime"/>
    8. <group name="Address">
    9. <add name="Street"/>
    10. <add name="City"/>
    11. <add name="State"/>
    12. <add name="Zipcode"/>
    13. </group>
    14. </properties>
    15. </profile>
    16.  
    17. </system.web>
    18. </configuration>

     

    So the details are saved now and you can insert it into the database you want.

    1. using System;
    2. using System.Data;
    3. using System.Configuration;
    4.  
    5. using System.Web;
    6. using System.Web.Security;
    7.  
    8. using System.Web.UI;
    9. using System.Web.UI.WebControls;
    10. using System.Web.UI.WebControls.WebParts;
    11. using System.Web.UI.HtmlControls;
    12.  
    13. public partial class _Default : System.Web.UI.Page
    14. {
    15. protected void Page_Load(object sender, EventArgs e)
    16. {
    17. if (!this.IsPostBack)
    18. {
    19. ProfileCommon pc=this.Profile.GetProfile(Profile.UserName);
    20. if (pc != null)
    21. {
    22. this.txtname.Text = pc.Name;
    23. this.txtaddr.Text = pc.Address.Street;
    24. this.txtcity.Text = pc.Address.City;
    25. this.txtstate.Text = pc.Address.State;
    26. this.txtzip.Text = pc.Address.Zipcode;
    27. this.Calendar1.SelectedDate = pc.Birthday;
    28. }
    29. }
    30. }
    31. }

    This is to display the detail of the user on page load.

     

    You can insert it the data of the user into the database by writing the following code:

    1. protected void btnsubmit_Click(object sender, EventArgs e)
    2. {
    3. ProfileCommon pc=this.Profile.GetProfile(Profile.UserName);
    4. if (pc != null)
    5. {
    6. pc.Name = this.txtname.Text;
    7. pc.Address.Street = this.txtaddr.Text;
    8. pc.Address.City = this.txtcity.Text;
    9. pc.Address.State = this.txtstate.Text;
    10. pc.Address.Zipcode = this.txtzip.Text;
    11. pc.Birthday = this.Calendar1.SelectedDate;
    12. pc.Save();
    13. }
    14. }
    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: