Archive

Archive for October, 2012

Call Button event in javascript

October 16, 2012 Leave a comment

function DoSearch() {
if (window.event.keyCode == 13) {
var btnSearch = document.getElementById(“”)
btnSearch.click();
window.event.cancel = true;
}
}

For Track which key was pressed

function doSomething(e) {
var code;
if (!e) var e = window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code);
alert(‘Character was ‘ + character);
}

Categories: JavaScript

Load assembly option from UI or Dynamic load assembly or get class object

October 15, 2012 Leave a comment

public static Assembly GetLoadedAssembly(string assemblyFullName)
{
Assembly assembly = null;

Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly asm in assemblies)
{
if (asm.FullName.Equals(assemblyFullName))
{
assembly = asm;
break;
}
}
return assembly;
}

public ClassNameToReturn GetClassObjects(string assemblyFullName)
{
Assembly assembly = GetLoadedAssembly(assemblyFullName);
if (assembly == null)
{
//load assembly as its not currently loaded in AppDomain
assembly = Assembly.LoadFrom(assemblyFullName);
}

Type eventType = assembly.GetType(eventHandler, false, true);
if (eventType == null)
{
throw new Exception();
}

object eventInstance = Activator.CreateInstance(eventType);
if (eventInstance == null)
{
throw new Exception();
}

ClassNameToReturn objClassNameToReturn = eventInstance as ClassNameToReturn ;
return objClassNameToReturn
}

Categories: C#