Date/Time Picker and Post

Thread is closed for posting
4 posts, 0 answers
  1. Cole
    Cole avatar
    20 posts
    Member since:
    Jun 2008

    Posted 03 Mar 2009 Link to this post

    Hey all,

    I have an MVC app that lets the user use the RadDate and RadTime pickers to choose a date and time for an event (separate inputs).  I read the documentation on how to extract the value... but having some problems when the page is submitted and there are errors.  Namely I want to:  A. Put the value back into the field from ViewData, B. Have a red border show up if the date is invalid (e.g. in the past, or is missing, etc.).

    When I try to do a simple <% if (ViewData["regform.Birthdate"]) {%>  etc. it says "Code blocks are not supported in this context".

    Anyone able to help me figure out whats going on with this?

    Thanks,
    Robin
  2. Cole
    Cole avatar
    20 posts
    Member since:
    Jun 2008

    Posted 04 Mar 2009 Link to this post

    Specifically...

    1. How do you set a value for RadDatePicker/RadTimePicker when running in ASP MVC?

    2. How would you set the border for RadDatePicker/RadTimePicker when running in ASP MVC?

    I am sure the two are the same approach... just not sure what iit is.

    Any help would be appreciated.

    Thanks,
    Rob
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Cole
    Cole avatar
    20 posts
    Member since:
    Jun 2008

    Posted 04 Mar 2009 Link to this post

    I found a solution... but not sure if it's the best approach.

    1. You have to do lots of testing for DateTime being of year 0001 when you extract the datetime to detect a null value.  Handle accordingly in your Controller.

    2, Create a code block ABOVE (did not work below) the elements in the page you wish to set value for and do manual insertion from ViewData (which was set in Controller action) to set the value

    3. I found that you have to set Selected date on BOTH the picker AND the DateInputField of the picker.  If you don't the value is lost during the next post. 

    4. To set error border, just set flag in the ViewData and check that in the same code block as #2 above.  Then do a MyDatePicker.DateInput.BorderColor = System.Drawing.Color.Red; (e.g.).

    Hope this helps, 
    Can a dev please comment on if there is a more efficient or robust way to do this?  It seems like a lot of hacking for what should be an easy task.

    As a suggestion... maybe create a "simple" way to bind the picker and button to an existing text field?  WIthout having to do the manual coding of onblur, dateselection changed etc.  When you have several pickers on your screen it can be a bit annoying to have to do the manual javascript coding for every one etc.

    HTH,
    Rob
  5. gyelle
    gyelle avatar
    4 posts
    Member since:
    Jan 2009

    Posted 04 Mar 2009 Link to this post

    thanks, was having the same problem :)
Back to Top