Selasa, 14 Januari 2014

How to create and read Profile Group in ASP.NET

Step-1: Add this code into web.config file

<?xml version="1.0"?>

<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>

    <system.web>
      <authentication mode="Windows" />
      <profile>
        <properties>
          <group name ="AuthorInfo">
            <add name="AuthorName"/>
            <add name ="age"/>
            <add name="rights"/>
              
            
          </group>

          <group name ="EditorInfo">

            <add name ="EditorName"/>
            <add name ="EditorMail"/>
            <add name ="Editorrights"/>
          </group>
          
        </properties>
      </profile>
        <compilation debug="false" targetFramework="4.0" />
    </system.web>

</configuration>

Step-2: Add this code into .aspx file
 
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">  
    protected void Page_Load(object sender, System.EventArgs e)  
    {
        // Author Information
        Profile.AuthorInfo.AuthorName = "Rhett Butler";
        Profile.AuthorInfo.age = "30";
        Profile.AuthorInfo.rights = "Article writing";
        
        // Editor Information

        Profile.EditorInfo.EditorName = "Jacob Lefore";
        Profile.EditorInfo.EditorMail = "narenkumar851@gmail.com";
        Profile.EditorInfo.Editorrights = "full rights";
        
        
       
        
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text += "<b>Author Information</b><br/>";
        Label1.Text += Profile.AuthorInfo.AuthorName+"<br/>";
        Label1.Text += Profile.AuthorInfo.age + "<br/>";
        Label1.Text += Profile.AuthorInfo.rights + "<br/>";
        Label1.Text += "<b>Editor Information</b><br/>";
        Label1.Text += Profile.EditorInfo.EditorName + "<br/>";
        Label1.Text += Profile.EditorInfo.EditorMail  + "<br/>";
        Label1.Text += Profile.EditorInfo.Editorrights + "<br/>";
        
        
        
        
        
        
    }
</script>  
  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>Get Lastupdated Date</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2>Create user Group</h2>
        <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Get user Group" 
            Width="169px" onclick="Button1_Click" />
        <br /><br />  
    </div>  
    </form>  
</body>  
</html>

Code Generate the following output

How to create and read Profile Group in ASP.NET

Tidak ada komentar:

Posting Komentar