You can use following code, if you want to know the user under which your ASP.NET application is running.
Add following namespace on top of your web page,
using System.Security.Principal;
Add following code to Page_Load event,
WindowsIdentity id = WindowsIdentity.GetCurrent();
Response.Write("Account Name: " + id.Name + "<br>");
The .NET Framework allows developers to use the same set of skills to rapidly buid great applications for the web, windows, services and more.
WindowsIdentity.GetCurrent().Name in ASP.NET
Display Current Time on the web page
Below example helps you to display current time on the web page. Textbox value will be updated with the current time every second.
Add following code to the page,
<script type="text/javascript">
function DisplayTime()
{
var currentDate = new Date();
document.getElementById("<%= TextTime.ClientID %>").value = currentDate.toLocaleTimeString();
window.setTimeout("DisplayTime()", 1000);
}
</script>
<script type="text/javascript">
window.setTimeout("DisplayTime()", 1000);
</script>
<asp:TextBox ID="TextTime" runat="server"></asp:TextBox>
Subscribe to:
Posts (Atom)