Click here to Skip to main content
15,891,734 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am having a lot of difficulty trying to start using the DateTimePicker/Calendar object from the Telerik ASP MVC Extensions toolbox kit. I want to REPLACE "@*<select id="Date" style="width:100px"></select>*@" WITH a DateTimePicker/Calendar object

C#
@{
ViewBag.Title = "Appointment Search";
Layout = "~/Views/Shared/_PhysioLayout.cshtml";

}

<h2>Appointment Search</h2>

<h2></h2>
<fieldset>
<h2>Please select a start date to generate schedule</h2><h6>Default is today</h6>
@*<select id="Date" style="width:100px">
</select>*@
<h2></h2>
<fieldset>
<legend>View By</legend>
<div><input id="Day" type="radio" /><h4>Day</h4></div>
<input id="Week" type="radio" /><h4>Week</h4>
<input id="Month" type="radio" /><h4>Month</h4>
<h2></h2>
</fieldset>
</fieldset>

@Html.ActionLink("Display Appointments", "Index")

<h2></h2>
<p>

@Html.ActionLink("Back to Home", "Index")
</p>


SQL
Basically, what I am trying to do, in the program, I am a physiotherapist, trying to search for different appointments that my patients have booked for, online. Instead of choosing the date and time from a drop down combo box, I want to display a DateTimePicker object or Calendar object where I can simply select a date and time and pass the value of date and time across to the controller where I can use it in other places in the program

I tried this method, as Carl Bergenhem displays in his video:

http://tv.telerik.com/watch/aspnet-mvc/getting-started-with-datetimepicker


C#
@(Html.Telerik().DateTimePicker()
.Name("MyDateTimePicker")
.Min(new DateTime(2011,1,1)
.Max(new DateTime(2012,1,1)
.Interval(30)
.Render()


But that only works in View pages that have been made in ASPX, which is not what I want

I also try doing this:

http://www.telerik.com/help/aspnet-mvc/getting-started-using-telerik-extensions-for-asp.net-mvc-in-your-project.html

But after getting to a point...when I type in Html., then "Telerik" doesn't appear in my Intellisense in Microsoft Visual Studio Ultimate 2010

Please suggest a simple tutorial on how to create the datetimepicker/calendar object in a View page that is made in Razor (CSHTML) in ASP.NET MVC 3. And also how to pass the values from there to a controller

Thank You
Posted

1 solution

Do you have a @using Telerik.Web.Mvc.UI directive at the top of your view? Then, do you have the following in your web.config in your Views folder, not the web.config in the root folder1:
<system.web.webPages.razor>
  <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  <pages pageBaseType="System.Web.Mvc.WebViewPage">
    <namespaces>
      ...
      <add namespace="Telerik.Web.Mvc" />
      <add namespace="Telerik.Web.Mvc.UI" />
    </namespaces>
  </pages>
</system.web.webPages.razor>


Then, the simplest 'tutorial' or quickstart is to look at the controller code and the Razor view code in the Telerik exmaples. You can find these locally if you chose to install them, or they are available online.

1 I doubt it hurts to have these in all the web.configs you want to, but it must be in the Views folder config.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900