/// <summary>
/// Gets the week number.
/// </summary>
/// <param name="dtDate">The date for which week number is required.</param>
/// <returns></returns>
public static int GetWeekNumber(DateTime dtDate)
{
CultureInfo culture = CultureInfo.CurrentCulture;
int weekNumber= culture.Calendar.GetWeekOfYear(dtDate, CalendarWeekRule.FirstFullWeek, DayOfWeek.Monday);
return weekNumber;
}
After this function I placed a server side Image control on my aspx page like this:-
<asp:Image ID="imgForWeek" runat="server" />
And here is how I called my function to display image for week in my code behind file:-
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
imgForWeek.ImageUrl = "../Images/image" + GetWeekNumber(DateTime.Now)+".jpg";
}
}
Hopefully this will be useful for you as well. Happy Coding !!!