Click here to Skip to main content
15,879,082 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionAsp.net Pin
Member 138185619-May-18 2:52
Member 138185619-May-18 2:52 
AnswerRe: Asp.net Pin
Richard MacCutchan9-May-18 3:35
mveRichard MacCutchan9-May-18 3:35 
AnswerRe: Asp.net Pin
ZurdoDev14-Jun-18 10:51
professionalZurdoDev14-Jun-18 10:51 
QuestionLooking for an example of food and drink on a handheld device ? Pin
Member 24584676-May-18 16:11
Member 24584676-May-18 16:11 
AnswerRe: Looking for an example of food and drink on a handheld device ? Pin
Richard MacCutchan6-May-18 21:54
mveRichard MacCutchan6-May-18 21:54 
QuestionClaimsIdentity with null referance Pin
Member 138120214-May-18 7:28
Member 138120214-May-18 7:28 
QuestionASP.NET MVC - Display all date/times in a specific time zone Pin
ZurdoDev3-May-18 8:14
professionalZurdoDev3-May-18 8:14 
AnswerRe: ASP.NET MVC - Display all date/times in a specific time zone Pin
Richard Deeming3-May-18 8:55
mveRichard Deeming3-May-18 8:55 
Something like this should work:

Views/Shared/DisplayTemplates/DateTime.cshtml:
@model DateTime?

if (Model != null)
{
    string formatString = ViewData.ModelMetadata.DisplayFormatString;
    if (string.IsNullOrWhiteSpace(formatString))
    {
        formatString = "{0:r}";
    }
    
    <time datetime="@string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:o}", Model)">@string.Format(System.Globalization.CultureInfo.CurrentCulture, formatString, Model?.ToLocalTime())</time>
}
Views/Shared/DisplayTemplates/DateTimeOffset.cshtml:
@model DateTimeOffset?

if (Model != null)
{
    string formatString = ViewData.ModelMetadata.DisplayFormatString;
    if (string.IsNullOrWhiteSpace(formatString))
    {
        formatString = "{0:r}";
    }
    
    <time datetime="@string.Format(System.Globalization.CultureInfo.CurrentCulture, "{0:o}", Model)">@string.Format(System.Globalization.CultureInfo.CurrentCulture, formatString, Model?.ToLocalTime())</time>
}

NB: This will use the server's local time zone, not the client's. If you want to use the client's, then you'll need to use Javascript to update the <time> elements. For example, using Moment.js[^]:
JavaScript
$(function () {
    $("time").each(function () {
        var me = $(this);
        var time = me.prop("dateTime");
        if (time) {
            var value = moment.utc(time);
            me.html(value.calendar());
            me.prop("title", value.format("LLLL"));
        }
    });
});




"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer

QuestionASP.NET web application for DVR integration Pin
Milind Panchal3-May-18 1:12
Milind Panchal3-May-18 1:12 
Questionerror:AjaxControlToolkit.RatingExtender missing required StarCssClass property Pin
Member 138022222-May-18 5:20
Member 138022222-May-18 5:20 
AnswerRe: error:AjaxControlToolkit.RatingExtender missing required StarCssClass property Pin
Richard Deeming2-May-18 8:43
mveRichard Deeming2-May-18 8:43 
PraiseRe: error:AjaxControlToolkit.RatingExtender missing required StarCssClass property Pin
Member 138022222-May-18 10:37
Member 138022222-May-18 10:37 
QuestionWhat technique can be used for printing ALL PAGES from crystal report?(asp.net,vb.net) Pin
Member 126093771-May-18 23:21
Member 126093771-May-18 23:21 
QuestionAm using entity framework of doing CRUD operation there for i take index .cshtml to show list of employees am getting stuck to get it please give a suggestions. Pin
Ankit Bopche29-Apr-18 23:33
Ankit Bopche29-Apr-18 23:33 
AnswerRe: I have recently taken over support of an ASP.NET MVC project, and am trying to work through some of the errors, one in particular has me stumped though. Pin
F-ES Sitecore30-Apr-18 0:15
professionalF-ES Sitecore30-Apr-18 0:15 
Questionam a beginner who want to learn ASP.net, how do I start Pin
Member 1380311528-Apr-18 17:17
Member 1380311528-Apr-18 17:17 
AnswerRe: am a beginner who want to learn ASP.net, how do I start Pin
Afzaal Ahmad Zeeshan29-Apr-18 2:10
professionalAfzaal Ahmad Zeeshan29-Apr-18 2:10 
GeneralMessage Closed Pin
4-May-18 23:19
hirasetup4-May-18 23:19 
JokeRe: am a beginner who want to learn ASP.net, how do I start Pin
Afzaal Ahmad Zeeshan5-May-18 2:22
professionalAfzaal Ahmad Zeeshan5-May-18 2:22 
GeneralRe: am a beginner who want to learn ASP.net, how do I start Pin
Richard Deeming9-May-18 8:39
mveRichard Deeming9-May-18 8:39 
QuestionPrinting Pin
Member 1360728318-Apr-18 18:17
Member 1360728318-Apr-18 18:17 
AnswerRe: Printing Pin
Richard MacCutchan18-Apr-18 21:59
mveRichard MacCutchan18-Apr-18 21:59 
GeneralRe: Printing Pin
Member 1360728319-Apr-18 3:27
Member 1360728319-Apr-18 3:27 
GeneralRe: Printing Pin
Richard MacCutchan19-Apr-18 3:57
mveRichard MacCutchan19-Apr-18 3:57 
GeneralRe: Printing Pin
MadMyche20-Apr-18 5:41
professionalMadMyche20-Apr-18 5:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.