Selasa, 14 Januari 2014

How to Get Last Activity Date of Profile user 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>
          <add name="UserName"/>
        </properties>
      </profile>
        <compilation debug="false" targetFramework="4.0" />
    </system.web>

</configuration>

Step-2: Add this code into .aspx page (Before add this code, please create profile first )

<%@ 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)  
    {
       
        
    }  

    protected void update_date(object sender, EventArgs e)
    {
        Label1.Text += "current Date and Time is " + DateTime.Now.ToString() +"<br/>";
        Label1.Text += "Profile LastUpdate Date is " + Profile.LastActivityDate; 
            
         

    }
</script>  
  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>Get Last Activity Date</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2>Get Last activity Date</h2>
        <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
        <br />
        <br />
        <asp:Button ID="Button1" runat="server" Text="Get Last Activity Date" 
            Width="169px" onclick="update_date" />
        <br /><br />  
    </div>  
    </form>  
</body>  
</html>
Code Generate the following output
How to Get Last Activity Date of Profile user in ASP.NET

Tidak ada komentar:

Posting Komentar