Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Put this in the body of Default page</p> <pre><code>&lt;body&gt; &lt;form id="form1" runat="server"&gt; &lt;table title="mxit:table:full" style="width: 100%;" align="center"&gt; &lt;tr style="background-color: red; text-align: center;"&gt; &lt;td style="width: 25%;"&gt; &lt;a href="Default.aspx?id=prev"&gt;&amp;lt; Prev&lt;/a&gt; &lt;/td&gt; &lt;td style="width: 50%;"&gt; &lt;asp:Label ID="lblMonth" runat="server"&gt;&lt;/asp:Label&gt;&amp;nbsp;&amp;nbsp; &lt;asp:Label ID="lblYear" runat="server"&gt;&lt;/asp:Label&gt; &lt;br /&gt; &lt;/td&gt; &lt;td style="width: 25%"&gt; &lt;a href="Default.aspx?id=next"&gt;Next &amp;gt;&lt;/a&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;asp:Label ID="lbltest" runat="server" Text=""&gt;&lt;/asp:Label&gt; &lt;/form&gt; &lt;/body&gt; </code></pre> <p>Put this in the code Behind Default.aspx.cs</p> <pre><code> using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { if (Request.QueryString["id"] == "next") { if ((int)Session["currentMonth"] &gt;= 12) { Session["currentMonth"] = 1; Session["currentYear"] = (int)Session["currentYear"] + 1; } else { Session["currentMonth"] = (int)Session["currentMonth"] + 1; } DateTime dt = new DateTime((int)Session["currentYear"], (int)(Session["currentMonth"]), 1); string obj = dt.DayOfWeek.ToString(); GetCalender(obj); } else if (Request.QueryString["id"] == "prev") { if ((int)Session["currentMonth"] &lt;= 1) { Session["currentMonth"] = 12; Session["currentYear"] = (int)Session["currentYear"] - 1; } else { Session["currentMonth"] = (int)Session["currentMonth"] - 1; } DateTime dt = new DateTime((int)Session["currentYear"], (int)(Session["currentMonth"]), 1); string obj = dt.DayOfWeek.ToString(); GetCalender(obj); } else //this will run when we start the project { int currentYear = DateTime.Now.Year; int currentMonth = DateTime.Now.Month; Session["currentMonth"] = currentMonth; Session["currentYear"] = currentYear; DateTime dt = new DateTime((int)Session["currentYear"], (int)(Session["currentMonth"]), 1); string obj = dt.DayOfWeek.ToString(); GetCalender(obj); } } catch { Response.Redirect("Default.aspx"); } } } private void GetCalender(string obj) { try { string[] months = new string[] {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; DayOfWeek objDayofweek = DateTime.Today.Date.DayOfWeek; lbltest.Text = "&lt;table style='width:100%' align='center'&gt;&lt;colgroup span='7' style='width:15%'&gt;&lt;/colgroup&gt;&lt;tr&gt;&lt;td&gt;Mon&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;Tue&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;Wed&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;Thu&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;Fri&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;Sat&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;Sun&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;"; int y = 1; switch (obj.ToString()) { case "Monday": y = 1; break; case "Tuesday": lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; y = 2; break; case "Wednesday": lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; y = 3; break; case "Thursday": lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; y = 4; break; case "Friday": lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; y = 5; break; case "Saturday": lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; y = 6; break; case "Sunday": lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; lbltest.Text = lbltest.Text + "&lt;td&gt;&amp;nbsp&lt;/td&gt;"; y = 7; break; } for (int dayday = Convert.ToInt32(objDayofweek); dayday &lt;= DateTime.DaysInMonth((int)Session["currentYear"], (int)(Session["currentMonth"])); dayday++) { if (y &lt; 7) { lbltest.Text = lbltest.Text + "&lt;td&gt;&lt;a href='#Date=" + dayday.ToString() + "/" + Session["currentMonth"] + "/" + Session["currentYear"] + "'&gt;" + dayday.ToString() + "&lt;/a&gt;&lt;/td&gt;"; y++; } else { lbltest.Text = lbltest.Text + "&lt;td&gt;&lt;a href='#Date=" + dayday.ToString() + "/" + Session["currentMonth"] + "/" + Session["currentYear"] + "'&gt;" + dayday.ToString() + "&lt;/a&gt;&lt;/td&gt;"; y = 1; lbltest.Text = lbltest.Text + "&lt;/tr&gt;&lt;tr&gt;"; } } lbltest.Text = lbltest.Text + "&lt;/tr&gt;&lt;/table&gt;"; lblMonth.Text = months[(int)Session["currentMonth"] - 1].ToString(); lblYear.Text = Session["currentYear"].ToString(); } catch { Response.Redirect("Default.aspx"); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload