I have just success using datepicker under ASP.NET MVC 4 when run from IDE VS2012. When I publish to IIS, this datepicker does not work. I'm sure that must be a configuration is needed, but I can not find it.
Any one can help me please how to solve my problem.
/* Styles to test new editor and display templates.
----------------------------------------------------------*/
.loud-1 {
/*font-weight: bold;*/
color: darkblue;
}
.loud-2 {
font-size: 2.0em;
color:Green;
}
.loud-3 {
font-style: italic;
color: yellow;
background-color: blue;
}
Here my bundling BundleConfig.cs:
using System.Web;
using System.Web.Optimization;
namespace evMonitoring
{
public class BundleConfig
{
// For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
"~/Scripts/jquery-ui-{version}.js",
"~/Scripts/DatePickerReady.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.unobtrusive*",
"~/Scripts/Apps/apps*",
"~/Scripts/jquery.validate*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/site.css",
"~/Content/PagedList.css",
"~/Content/CustomStyle.css"
));
bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
"~/Content/themes/base/jquery.ui.core.css",
"~/Content/themes/base/jquery.ui.resizable.css",
"~/Content/themes/base/jquery.ui.selectable.css",
"~/Content/themes/base/jquery.ui.accordion.css",
"~/Content/themes/base/jquery.ui.autocomplete.css",
"~/Content/themes/base/jquery.ui.button.css",
"~/Content/themes/base/jquery.ui.dialog.css",
"~/Content/themes/base/jquery.ui.slider.css",
"~/Content/themes/base/jquery.ui.tabs.css",
"~/Content/themes/base/jquery.ui.datepicker.css",
"~/Content/themes/base/jquery.ui.progressbar.css",
"~/Content/themes/base/jquery.ui.theme.css"));
}
}
}
I have add ajaxcontroltoolkit.dll using nuget in my project reference and publish the project. I have also checked that the dll include at the bin folder. But I have no luck yet.
I'm still trying to read deployment guide, hope I can have the solution.
jsiahaan
Contributor
2550 Points
645 Posts
DatePicker does not work under IIS, but it works when run from IDE Visual Studio 2012
Feb 24, 2013 02:40 PM|LINK
Hi,
I have just success using datepicker under ASP.NET MVC 4 when run from IDE VS2012. When I publish to IIS, this datepicker does not work. I'm sure that must be a configuration is needed, but I can not find it.
Any one can help me please how to solve my problem.
Thanks
Indonesian Humanitarian Foundation
ignatandrei
All-Star
137690 Points
22151 Posts
Moderator
MVP
Re: DatePicker does not work under IIS, but it works when run from IDE Visual Studio 2012
Feb 24, 2013 04:15 PM|LINK
How did you register the js?
Danny117
Star
11160 Points
1932 Posts
Re: DatePicker does not work under IIS, but it works when run from IDE Visual Studio 2012
Feb 24, 2013 04:40 PM|LINK
Probably the ajaxcontroltoolkit.dll is missing from IIS. You just drop it in the bin folder.
Me on linked in
jsiahaan
Contributor
2550 Points
645 Posts
Re: DatePicker does not work under IIS, but it works when run from IDE Visual Studio 2012
Feb 24, 2013 09:28 PM|LINK
Hi ignatandrei,
First thanks for your reply.
Here my js DatePickerReady.js:
$(function () { $(".datefield").datepicker({ dateFormat: 'dd/mm/yy' }); });Here my CSS :
/* Styles to test new editor and display templates. ----------------------------------------------------------*/ .loud-1 { /*font-weight: bold;*/ color: darkblue; } .loud-2 { font-size: 2.0em; color:Green; } .loud-3 { font-style: italic; color: yellow; background-color: blue; }Here my bundling BundleConfig.cs:
using System.Web; using System.Web.Optimization; namespace evMonitoring { public class BundleConfig { // For more information on Bundling, visit http://go.microsoft.com/fwlink/?LinkId=254725 public static void RegisterBundles(BundleCollection bundles) { bundles.Add(new ScriptBundle("~/bundles/jquery").Include( "~/Scripts/jquery-{version}.js")); bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include( "~/Scripts/jquery-ui-{version}.js", "~/Scripts/DatePickerReady.js")); bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include( "~/Scripts/jquery.unobtrusive*", "~/Scripts/Apps/apps*", "~/Scripts/jquery.validate*")); // Use the development version of Modernizr to develop with and learn from. Then, when you're // ready for production, use the build tool at http://modernizr.com to pick only the tests you need. bundles.Add(new ScriptBundle("~/bundles/modernizr").Include( "~/Scripts/modernizr-*")); bundles.Add(new StyleBundle("~/Content/css").Include( "~/Content/site.css", "~/Content/PagedList.css", "~/Content/CustomStyle.css" )); bundles.Add(new StyleBundle("~/Content/themes/base/css").Include( "~/Content/themes/base/jquery.ui.core.css", "~/Content/themes/base/jquery.ui.resizable.css", "~/Content/themes/base/jquery.ui.selectable.css", "~/Content/themes/base/jquery.ui.accordion.css", "~/Content/themes/base/jquery.ui.autocomplete.css", "~/Content/themes/base/jquery.ui.button.css", "~/Content/themes/base/jquery.ui.dialog.css", "~/Content/themes/base/jquery.ui.slider.css", "~/Content/themes/base/jquery.ui.tabs.css", "~/Content/themes/base/jquery.ui.datepicker.css", "~/Content/themes/base/jquery.ui.progressbar.css", "~/Content/themes/base/jquery.ui.theme.css")); } } }Here my _Layout.cshtml:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>@ViewBag.Title - @Assets.Resource.EntitySmallName</title> <link href="~/Images/logo032.png" rel="shortcut icon" type="image/x-icon" /> <meta name="viewport" content="width=device-width" /> @Styles.Render("~/Content/css") @Styles.Render("~/Content/themes/base/css") @* Date Picker*@ @Scripts.Render("~/bundles/modernizr") </head> <body> <header> .... .... .... </header> <div id="body"> @RenderSection("featured", required: false) <section class="content-wrapper main-content clear-fix"> @RenderBody() </section> </div> <footer> <div class="content-wrapper"> <div class="float-left"> <p>© @DateTime.Now.Year - @IntegratedResource.Asset.AppsResource.CopyRight</p> </div> </div> </footer> @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/jqueryui") @* Date Picker*@ @RenderSection("scripts", required: false) </body> </html>Here my date template date.cshtml:
@model DateTime @Html.TextBox("", String.Format("{0:d}", Model.ToShortDateString()), new { @class = "datefield", type = "date" })These are what I have done. Is this the register you mean? I put bundling my js
Indonesian Humanitarian Foundation
jsiahaan
Contributor
2550 Points
645 Posts
Re: DatePicker does not work under IIS, but it works when run from IDE Visual Studio 2012
Feb 24, 2013 09:39 PM|LINK
Hi Danny117,
Thanks for your reply.
I have add ajaxcontroltoolkit.dll using nuget in my project reference and publish the project. I have also checked that the dll include at the bin folder. But I have no luck yet.
I'm still trying to read deployment guide, hope I can have the solution.
Indonesian Humanitarian Foundation
Young Yang -...
All-Star
21741 Points
1825 Posts
Microsoft
Re: DatePicker does not work under IIS, but it works when run from IDE Visual Studio 2012
Mar 03, 2013 12:59 AM|LINK
It seems that your javascript is not deployed properly. Use Url.Content for the relative path.
Hope this helpful
Regards
Feedback to us
Develop and promote your apps in Windows Store
jsiahaan
Contributor
2550 Points
645 Posts
Re: DatePicker does not work under IIS, but it works when run from IDE Visual Studio 2012
Mar 03, 2013 01:08 AM|LINK
Thank's Young Yang,
Several javaScript work fine. Only datePicker pop-up is not shown.
All the path are shown on my posting above. Both .css and .js are bundled.
Could you please check it back for me?
Thanks you so much
Indonesian Humanitarian Foundation