Wednesday, March 21, 2007

Advanced User Control Creation Tips


Hi,

Today I am going to discuss about 2 approaches for UserControl creation in ASP.NET

My requirement was to create a control that can hold other controls as child control. In case of User Controls we don't have the option of using a container control like "Panel" as all the User Controls must inherit for the UserControl class.

I will explain a scenario, where it might make sense:
You are building a control which has lots of tables and images etc. So creating a custom control can be really difficult. But the actual requirement is to use this control as like a container control which can hold any other control. This is more of a requirement when you want to use the designer HTML view to create your page.

The approaches are
1. Create a templated control
2. Define a child control container for the User Control

both approaches are easy, but the templated one can be treated as the easiest. But this approach has a problem. The controls that are used inside the Template property cannot be referenced in the main class, that means you need to use the "FindControl" method to access these controls from code behind.

I will explain each approach in subsequent blogs

Labels:

Saturday, March 10, 2007

Hi,

I was trying to bring my blog in the eyes of search engines. I searched a lot for tips that will enable me to do that. Fortunately I found a site http://www.microsoft.com/smallbusiness/resources/marketing/online_marketing/help_people_find_your_web_site_8_tips.mspx

This site gives you enough tips for keeping your site known to search engines. Here are some URLs that you might be interested in:
Google: http://www.google.com/addurl/?continue=/addurl
Yahoo!: http://tinyurl.com/5oclp (registration required)
MSN: http://beta.search.msn.com/docs/submit.aspx

So... After a long gap of few months, I thought of writing a new blog. I am in Seattle, WA. The Rain City. It was too cold when I came here in January. Covered with snow for more than a week. I never went out of my home, since cold was too much for me.

I was working with one of my clients, who was into mobile applications. A new area, for me. It was even difficult than the web stuff. Here you need to write code that works in various devices that has different capabilities. When I was working with web, I thought browsers are the worst platform one can ever write applications for. Now I realised that there is always a worse thing than what you deal with.

The problems are so many. You need to think about WAP devices, XHTML enabled devices, small screen devices, black and white devices, and smart devices and what not. Frankly speaking this is a nut that is hard to crack. Each vendor has their own style of doing it.

So our client created a common platform that leverage the mobile .NET platform. It uses specific things like different CSS, different rendering etc for each specific device that falls out of the common-ally. Such a pain, you know, the testing...

So we use a new design pattern called Model View Presenter. This enables us to do proper unit testing without the hassles of ASP.NET page architecture. You can have different views with same presenter, which allows us to create Mock views for testing purpose. Checkout the benefits of using MVP model. Later I will write a full blog on how to go about leverging the maximum throughput of MVP.