Tuesday, October 21, 2008

Using Session Variables in JavaScript - ASP.NET, C#

Using Session Variables in JavaScript - ASP.NET, C#

var apptMultiple ='<%= Session["multipleAppointments"]%>';

function SetRelationOnForm(){
var relation = '<%=Session["consentrelationshipToPatient"] %>';
var isPat = '<%=Session["consentSelIsPatient"] %>';
var isPatRep = '<%=Session["consentIsPatientRepresentative"] %>';
}

Friday, July 11, 2008

Getting Client Host name using Java Script/C#

Getting Client Host name using Java Script

function GetComputerName()
{
try
{
var WshNetwork = new ActiveXObject("WScript.Network");
var hostname = WshNetwork.ComputerName.toLowerCase(); document.getElementById('HdnMachineId').value = hostname;
}
catch(err)
{ }
}

Getting Client Host name using C#

private string getClientHostName()
{
// Get HostName of client computer
string hostname = HttpContext.Current.Request.ServerVariables["REMOTE_HOST"].ToString().ToLower();
try
{
System.Net.IPHostEntry host = System.Net.Dns.GetHostByAddress(hostname);
hostname = host.HostName;
}
catch(Exception exp)
{

}
return hostname;
}