The difference between Margin and Padding properties

Margin and Padding are two similar layout concepts that are often confused. Margin represents the amount of space around the outside of the element. This space ensures that the Element has room between it and neighboring elements. Padding functions differently. It is present on elements that inherit from Control  and allows the control to specify an amount of space inside itself. This inner space separates the control from its own content.  Take for example the Button control. The space inside the Button, around its text, that prevents the Button‘s border from shrinking to the size of its contents. Take a look at the below diagram which illustartes the differenece more.

marginandpadding

Microsoft’s Official Team Blogs Directory

The link contains a listing of all Microsoft’s team blogs.

http://blogs.technet.com/blogms/pages/directory-of-microsoft-team-blogs.aspx

Caching part of an ASP.Net Page

Sometimes you need to cache only a portion of an ASP.Net page that is not dynamically changing much.  You can achieve partial caching through several methods:

First, You can simply do that by adding the portion that you want to cache to a user control and configure that user control to be cached by adding the page directive to the control header.


<%@ OutputCache Duration="15" VaryByParam="none" %>

 

Doing that the user control will be cached separately from the  ASP.Net page and it will be rendered only once until the cache duration expires.

An alternative to using user controls and caching you can use the Substitution Control which is similar to a label control but is exempted from the the OutputCache directive. You simple set the  Substitution.MethodName with the method responsible for dynamically generating the content, for example, retrieving values from a database. The specified method must accept an HttpContext object as a parameter and returns a string that is going to be written to the response withing the Substitution Control. For example, suppose you want to add a dynamic portion of a cached page that displays the time.
you will add a Substitution Control to the page where you want display the time and then add the following code:

void Page_Load(object sender, System.EventArgs e)
{
// Specify the callback method.
timeSubstitution.MethodName = "GetTime";
}
public static string GetTime(HttpContext context)
{
return DateTime.Now.ToString();
}

Adding multiple web controls on the same line in ASP.Net Mobile forms

When developing ASP.NET mobile forms, by default, each control is added on a single line. However, you can still add multiple controls on the same line by setting the  BreakAfter property to false of the control you want to add a control after and appear on the same line. This property is set by default to true and it is advisable to keep as it is and display only one control per line in order to maintain a linear behavior.