Find number of Days in a Month

How to find number of Days in a given Month from a web application or windows application? Copy one line of code in your page.


Response.Write(DateTime.DaysInMonth(2010, 7));

The above line should display result as 31.

Add Website URL to your Favorites Menu from web application

How to add a website/webiste URL to your Favorites Menu from an application? You can copy below sample code to your .aspx page and you are all set.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AddToFavoritesMenu.aspx.cs" Inherits="AddToFavoritesMenu" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<head id="Head1" runat="server">
<script type="text/javascript">
function AddToFavoriteMenu() {
window.external.AddFavorite("", ".NET Sample Code");
<form id="form1" runat="server">
<input id="Button1" type="button" value="Click here to Add to favorites Menu.." onclick="AddToFavoriteMenu()" />

When you click the button on the webpage, it will prompt a nice InputBox (same InputBox when you click on ‘Add to Favorites…’ on your browser). You can change the defualt name or you can click on Add to add it in your favorites menu.