Category Archives: Microsoft.Net

Type.GetType()

Browsing through ASP.NET Forums, I found an interesting questions raised by a member that when he tried to get type information of a class using Type.GetType it was a charm in C#, but VB did not worked in same manners. He was trying to create new instances of that class at runtime, and populate those instances with data fetched from any database.

I checked its documentation in MSDN, here are its salient points, which should always be thought out before using this.

It accepts only a parameter which must contain an assembly qualified name of required type. This parameter could be only type name (i.e. "Contact") or may include namespace in it (i.e. "Hansvits.Models.Contact").

If parameter has only type name then method will search only in the assembly in which that call was made. If any full/partial assembly name is mentioned then it will load that assembly and search in it.

Continue reading

Disabling ASPX Controls on client side

To enable or disable .Net controls on client side use following scripts.

//To Disable
document.getElementById(element_client_id).setAttribute('disabled','true');

//To Enable
document.getElementById(element_client_id).removeAttribute('disabled');

Nearly all html rendered control would adher to this coding guide, but aspx checkbox has a span element wrapped up on it. To disable checkbox properly add a extra line as below.

document.getElementById(element_client_id).parentElement.removeAttribute('disabled');