Subscribe to Feed

15Sep

How to prevent a Custom Control in Asp.Net from being adapted?

Posted by admin as .Net, Asp.Net, Microsoft, Technology, Web

 

For the starters, Adaptive control behavior is control behavior that is customized for target devices. ASP.NET provides an adaptive architecture that allows key life cycle stages of a control to be intercepted and substituted with custom behavior. A common example of adaptive control behavior is adaptive rendering where an ASP.NET Web page is rendered specific to the browser or markup. This is especially useful for writing applications that support browsers that use different markup languages. for more information refer to the MSDN article here.

Sometimes, when you are writing a custom control that uses Asp.Net control controls like menu etc which has Adaptive rendering built in, you might wish to turn that behavior off for what ever reason. (May be you have your own adaptive rendering logic and wish to display the menu in a different way than that of default Asp.Net’s!) Here is a simple trick to block default adaptive rendering in your custom control: Override the ResolveAdapter method in the custom control to return null always.

 

protected override ControlAdapter ResolveAdapter()
{
    return null; // instead of base.ResolveAdapter()
}

 

That’s it and you are all set.

Hope this helps some one.

Comment Form

 

 

Subscribe to Feed

Categories

Links

Dev Jobs