Page view counter

Adding Date to MasterPage.master using C# not JS

Last post 09-16-2006 7:17 PM by Kadjiokou. 1 replies.

Sort Posts:

  • Adding Date to MasterPage.master using C# not JS

    09-16-2006, 3:20 AM
    • Loading...
    • akent
    • Joined on 08-31-2006, 12:51 AM
    • Los Angeles, CA
    • Posts 32
    • Points 142

    I want to add the Date above the Menu in the top right corner like: Friday, 15 September 2006; i wrote some basic javascript to take care of it, and it works great in IE and Firefox, however, regarding SEO one might argue that Google wont be able to read the date as: Friday, 15 September 2006; but as document.write( weekday[d.getDay()] + ", " + d.getDate() + " " + month[d.getMonth()] + " " + d.getFullYear())    hence i rather use some server side code but i havent used a MasterPage.master before, seems to be no codebehind file? How can i insert the current date using C# or VB.NET into the MasterPage.master file??

    <div id="LayerDate">

    <script type="text/javascript">

    <!--

    var d=new Date()

    var weekday=new Array(7)

    weekday[0]="Sunday"

    weekday[1]="Monday"

    weekday[2]="Tuesday"

    weekday[3]="Wednesday"

    weekday[4]="Thursday"

    weekday[5]="Friday"

    weekday[6]="Saturday"

    var month = new Array(12)

    month[0] = "January"

    month[1] = "February"

    month[2] = "March"

    month[3] = "April"

    month[4] = "May"

    month[5] = "June"

    month[6] = "July"

    month[7] = "August"

    month[8] = "September"

    month[9] = "October"

    month[10] = "November"

    month[11] = "December"

    document.write( weekday[d.getDay()] + ", " + d.getDate() + " " + month[d.getMonth()] + " " + d.getFullYear())

    -->

    </script>

     

    </div>

  • Re: Adding Date to MasterPage.master using C# not JS

    09-16-2006, 7:17 PM
    • Loading...
    • Kadjiokou
    • Joined on 07-12-2005, 4:59 AM
    • Posts 314
    • Points 1,412

     

    You could place the line below wherever appropriate in MasterPage.master :

    <asp:Label ID="MyDateLabelId" runat="server" Text='<%# System.DateTime.Now.ToLongDateString() %>'></asp:Label>

    You can format the date as you want it.

    HTH

    /Kadji 

     

     

Page 1 of 1 (2 items)