Yaz  Font K   lt Yaz  Font B y lt

Asp.net te Profil Kullan m

 

Merhaba arkada lar bu makalemizde asp.net te profil kullan m rne i yapaca z.

web.config dosyas na

 

<profile>

        <properties>

          <add name="Name" type ="String"/>

          <add name="Birthday" type ="System.DateTime"/>

 

          <group name="Address">

            <add name="Street"/>

            <add name="City"/>

            <add name="State"/>

            <add name="Zipcode"/>

          </group>

 

        </properties>

      </profile>

 

 

Screenshot

Ekleyin.

Resim1

ekil 1



Resim2 

ekil 2

 

Default.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Configuration;

 

using System.Web.Security;

 

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {

        if (!this.IsPostBack)

        {

            ProfileCommon pc = this.Profile.GetProfile(Profile.UserName);

 

            if (pc != null)

            {

                this.txtname.Text = pc.Name;

                this.txtaddr.Text = pc.Address.Street;

                this.txtcity.Text = pc.Address.City;

                this.txtstate.Text = pc.Address.State;

                this.txtzip.Text = pc.Address.Zipcode;

                this.Calendar1.SelectedDate = pc.Birthday;

            }

        }

    }

    protected void btnsubmit_Click(object sender, EventArgs e)

    {

        ProfileCommon pc = this.Profile.GetProfile(Profile.UserName);

 

        if (pc != null)

        {

            pc.Name = this.txtname.Text;

            pc.Address.Street = this.txtaddr.Text;

            pc.Address.City = this.txtcity.Text;

            pc.Address.State = this.txtstate.Text;

            pc.Address.Zipcode = this.txtzip.Text;

            pc.Birthday = this.Calendar1.SelectedDate;

 

            Label1.Text = "Profil ba ar l bir ekilde kaydedildi!" +

            "<br />Ad ve Soyad: " + pc.Name +

           "<br />Adres: " + pc.Address.Street   +

            "<br /> ehir: " + pc.Address.City +

            "<br /> lke: " + pc.Address.State +

           "<br />Kod: " + pc.Address.Zipcode   +

            "<br />Do um Tarihi: " + pc.Birthday ;

 

 

            pc.Save();

        }

    }

}

 

Default.aspx

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

 

<!DOCTYPE html>

 

<html xmlns="http://www.w3.org/1999/xhtml">

 

<head runat="server">

    <title></title>

 

</head>

<body>

    <form id="form1" runat="server">

    <div>

    <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label>

        <br /><br />

        <asp:Label ID="Label2" runat="server" Text="Ad Soyad" AssociatedControlID="txtname"></asp:Label>

        <asp:TextBox ID="txtname" runat="server"></asp:TextBox>

        <br />

        <asp:Label ID="Label3" runat="server" Text="Adres" AssociatedControlID="txtaddr"></asp:Label>

        <asp:TextBox ID="txtaddr" runat="server"></asp:TextBox>

        <br />

        <asp:Label ID="Label4" runat="server" Text=" ehir" AssociatedControlID="txtcity"></asp:Label>

        <asp:TextBox ID="txtcity" runat="server"></asp:TextBox>

        <br />

        <asp:Label ID="Label5" runat="server" Text=" lke" AssociatedControlID="txtstate"></asp:Label>

        <asp:TextBox ID="txtstate" runat="server"></asp:TextBox>

        <br />

        <asp:Label ID="Label6" runat="server" Text="Kod" AssociatedControlID="txtstate"></asp:Label>

        <asp:TextBox ID="txtzip" runat="server"></asp:TextBox>

        <br />

        <asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>

        <br />

        <br />

        <asp:Button ID="btn1" runat="server" Text="Profil Ekle" OnClick="btnsubmit_Click" />

 

    </div>

    </form>

</body>

</html>

 

     

Bir makalenin daha sonuna geldik. Bir sonraki makalede gorusmek uzere. Bahadir SAHIN