locked
i want to display date on each linkbutton in asp.net RRS feed

  • Question

  • i want to display each date on each linkbutton dynmically in asp.net

    please solve the problem

     DateTime start = new DateTime(2013, 04, 16);
            DateTime end = new DateTime(2013, 04, 20);
            DataTable dtt=new DataTable ();
            var dates = new List<string>();

            for (var dt = start; dt <= end; dt = dt.AddDays(1))
            {

                string day=dt.DayOfWeek.ToString();
                dates.Add(dt.ToString("dd") +" "+   day);

            }

            Response.ContentType = "text/javascript";
            string json = new JavaScriptSerializer().Serialize(dates);
            LinkButton lnkEmployee = new LinkButton();
            lnkEmployee.Text = json;
            Response.Write(json);
            Response.End();
        }




                           
    • Moved by Jason Dot Wang Thursday, April 18, 2013 6:48 AM This thread is about ASP.NET
    Wednesday, April 17, 2013 5:57 AM

Answers

  • Hi ankit1516,

      Welcome to MSDN Forum Support.

      You are more likely to get more efficient responses to ASP.NET issues at http://forums.asp.net where you can contact ASP.NET experts.



    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    • Proposed as answer by Carey FrischMVP Friday, April 19, 2013 5:11 AM
    • Marked as answer by Just Karl Wednesday, October 9, 2013 2:52 PM
    Thursday, April 18, 2013 6:48 AM

All replies

  • dear ankit 

     Please see this code where it will show no. of linkbuttons with your previous response.write text. If you don't want only text just ommit Response.Write(json);

     DateTime start = new DateTime(2013, 04, 16);
            DateTime end = new DateTime(2013, 04, 20);
            DataTable dtt = new DataTable();
            var dates = new List<string>();

            for (var dt = start; dt <= end; dt = dt.AddDays(1))
            {

                string day = dt.DayOfWeek.ToString();
                dates.Add(dt.ToString("dd") + " " + day);
                //Response.ContentType = "text/javascript";
                string json = new JavaScriptSerializer().Serialize(dates);
                LinkButton lnkEmployee = new LinkButton();
                lnkEmployee.ID = "lbtn" + day; 
                lnkEmployee.Text = json;
                Response.Write(lnkEmployee.Text);
                Panel1.Controls.Add(lnkEmployee);//For linkbutton display
                // Response.End();
            }


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.

    Wednesday, April 17, 2013 11:00 AM
  • Hi ankit1516,

      Welcome to MSDN Forum Support.

      You are more likely to get more efficient responses to ASP.NET issues at http://forums.asp.net where you can contact ASP.NET experts.



    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    • Proposed as answer by Carey FrischMVP Friday, April 19, 2013 5:11 AM
    • Marked as answer by Just Karl Wednesday, October 9, 2013 2:52 PM
    Thursday, April 18, 2013 6:48 AM