From a1c331c060c4e0d82f14bfc67127889a6d36562e Mon Sep 17 00:00:00 2001 From: afsharm Date: Sun, 31 Aug 2014 11:48:43 +0430 Subject: [PATCH 1/2] resolved bug in MVC Models with nested Items --- .../Views/Shared/EditorTemplates/PersianDate.cshtml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/PersianDatePicker-MVC/Views/Shared/EditorTemplates/PersianDate.cshtml b/PersianDatePicker-MVC/Views/Shared/EditorTemplates/PersianDate.cshtml index 5244c7f..51dcbc6 100644 --- a/PersianDatePicker-MVC/Views/Shared/EditorTemplates/PersianDate.cshtml +++ b/PersianDatePicker-MVC/Views/Shared/EditorTemplates/PersianDate.cshtml @@ -26,6 +26,10 @@ last edit: 25/07/2013 day = '0' + day.toString(); var textboxname = $(this).attr('name'); var textboxnamewithoutprefix = textboxname.substring(0, textboxname.indexOf('.EnglishDateTextbox')); + + //in Models that have nested item '.' must be replace to '_' otherwise getElementById will fail + textboxnamewithoutprefix = textboxnamewithoutprefix.replace('.', '_'); + document.getElementById(textboxnamewithoutprefix).value = date.getFullYear() + '/' + month + '/' + day; } }); From c6c1e74a19998555d2f4ecd9767fb66dca5567b7 Mon Sep 17 00:00:00 2001 From: afsharm Date: Thu, 25 Dec 2014 13:37:04 +0330 Subject: [PATCH 2/2] a missed commit --- PersianDatePicker-MVC/PersianDateExtension.cs | 118 +++++++++--------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/PersianDatePicker-MVC/PersianDateExtension.cs b/PersianDatePicker-MVC/PersianDateExtension.cs index ca8caa7..7d1c314 100644 --- a/PersianDatePicker-MVC/PersianDateExtension.cs +++ b/PersianDatePicker-MVC/PersianDateExtension.cs @@ -1,60 +1,60 @@ -//By: Bahman Nikkhahan -//February 2013 -using System; -using System.Collections.Generic; -using System.Linq; -using System.Web; - -namespace PersianDatePicker_MVC -{ - public static class PersianDateExtension - { - public static string GetPersianDateString(DateTime? date) - { - string PersianDate = ""; - if (!date.HasValue) - { - return PersianDate; - } - System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar(); - int Year = p.GetYear(date.Value); - int Month = p.GetMonth(date.Value); - int Day = p.GetDayOfMonth(date.Value); - string MonthName = "فروردین"; - switch (Month) - { - case 1: { MonthName = "فروردین"; break; } - case 2: { MonthName = "اردیبهشت"; break; } - case 3: { MonthName = "خرداد"; break; } - case 4: { MonthName = "تیر"; break; } - case 5: { MonthName = "مرداد"; break; } - case 6: { MonthName = "شهریور"; break; } - case 7: { MonthName = "مهر"; break; } - case 8: { MonthName = "آبان"; break; } - case 9: { MonthName = "آذر"; break; } - case 10: { MonthName = "دی"; break; } - case 11: { MonthName = "بهمن"; break; } - case 12: { MonthName = "اسفند"; break; } - default: { MonthName = "فروردین"; break; } - } - PersianDate = Day.ToString() + " " + MonthName + " " + Year.ToString(); - return PersianDate; - } - public static string GetPersianDateStringSlashed(DateTime? date) - { - string PersianDate = ""; - if (!date.HasValue) - { - return PersianDate; - } - System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar(); - int Year = p.GetYear(date.Value); - int Month = p.GetMonth(date.Value); - int Day = p.GetDayOfMonth(date.Value); - - PersianDate = Day.ToString() + "/" + Month.ToString() + "/" + Year.ToString(); - return PersianDate; - } - - } +//By: Bahman Nikkhahan +//February 2013 +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace PersianDatePicker_MVC +{ + public static class PersianDateExtension + { + public static string GetPersianDateString(DateTime? date) + { + string PersianDate = ""; + if (!date.HasValue) + { + return PersianDate; + } + System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar(); + int Year = p.GetYear(date.Value); + int Month = p.GetMonth(date.Value); + int Day = p.GetDayOfMonth(date.Value); + string MonthName = "فروردین"; + switch (Month) + { + case 1: { MonthName = "فروردین"; break; } + case 2: { MonthName = "اردیبهشت"; break; } + case 3: { MonthName = "خرداد"; break; } + case 4: { MonthName = "تیر"; break; } + case 5: { MonthName = "مرداد"; break; } + case 6: { MonthName = "شهریور"; break; } + case 7: { MonthName = "مهر"; break; } + case 8: { MonthName = "آبان"; break; } + case 9: { MonthName = "آذر"; break; } + case 10: { MonthName = "دی"; break; } + case 11: { MonthName = "بهمن"; break; } + case 12: { MonthName = "اسفند"; break; } + default: { MonthName = "فروردین"; break; } + } + PersianDate = Day.ToString() + " " + MonthName + " " + Year.ToString(); + return PersianDate; + } + public static string GetPersianDateStringSlashed(DateTime? date) + { + string PersianDate = ""; + if (!date.HasValue) + { + return PersianDate; + } + System.Globalization.PersianCalendar p = new System.Globalization.PersianCalendar(); + int Year = p.GetYear(date.Value); + int Month = p.GetMonth(date.Value); + int Day = p.GetDayOfMonth(date.Value); + + PersianDate = Day.ToString() + "/" + Month.ToString() + "/" + Year.ToString(); + return PersianDate; + } + + } }