SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Newbie

  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Newbie



    Hi this is a code excerpt from a book...


    void SelectionChanged(object s, EventArgs e)
    {
    myLabel.Text="";
    foreach(DateTime d in myCalandar.SelectedDates)
    {
    myLabel.Text += d.ToString("D") +"<br/>";
    }
    }
    I am confused by the code, because the bit d.Tostring("D"), i can not see where or how D is defined....


    here is the whole file...... it works.... but i am stuck.
    d is defined in the foreach loop, but what about D....?

    Thanks in advance sorry for being so dense....



    <DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict."dtd">
    <html>
    <head>
    <title>Calender Test</title>
    <script runat="server" language="C#">
    void SelectionChanged(object s, EventArgs e)
    {
    myLabel.Text="";
    foreach(DateTime d in myCalandar.SelectedDates)
    {
    myLabel.Text += d.ToString("D") +"<br/>";
    }
    }

    </script>
    </head>
    <body>
    <form runat="server">
    <asp:Calendar id="myCalandar" runat="server" DayNameFormat="Short"
    FirstDayOfWeek="Sunday" NextPrevFormat="FullMonth" SelectionMode="DayWeekMonth"
    SelectWeekText="Select Week" SelectMonthText="Select Month" TitleFormat="Month"
    OnSelectionChanged="SelectionChanged" />
    <h2>You selected these dates</h2>
    <asp:Label ID="myLabel" runat="server" />
    </form>
    </body>
    </html>

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,608
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    This is .NET not ASP. Nevertheless, I presume that "D" is an option for the .toString() function call to insure the string is in a date format.
    Ian Anderson
    www.siteguru.co.uk


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •