Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Getting StartedGetting StartedKnockoutJS, DNN, SQL Server and datesKnockoutJS, DNN, SQL Server and dates
Previous
 
Next
New Post
3/20/2012 3:25 PM
 
Hi

Does anybody have any specific examples of using DNN 6/knockoutjs/entityframework/sql server and dates? Nothing seems to be coming up trumps at all :(

Specifically I enter a date of birth in an ASP.NET webform like 22/05/1970 (or even better use a calender control or something), and this posts the date via javascript (via knockoutJS):

Right now I initialise like this:

DOB: ko.observable(new Date())

or maybe even like this:

DOB: ko.observable()

This is how my postData is handled:

 DOB: viewModel.DOB()

 

And this is my form which I type in:

<div class="dnnFormItem">
<dnn:label id="plDOB" runat="server" controlName="txtDOB"></dnn:label> <asp:TextBox id="txtDOB" runat="server" data-bind="date: DOB"></asp:TextBox>
</div>

Ultimately this goes into a SQL Server datetime field!

So far postings on other forums have been far too much for my tiny brain to handle, so I'm posting here as an act of despiration! I seem to have no problem with other value types.

Has anybody actually done this within DNN? Could you share a full example?

Cheers

Alex



Alex Shirley


 
New Post
3/20/2012 3:46 PM
 

Alex,

  I am not familiar with using KnockoutJS with server controls.  It seems like it kind of defeats the whole point of KnockoutJS.  In your example, why would you not just do the data-binding on the server side since you are using server controls?

Have you tried stepping into the debugger to see what value comes back in the form post?  Dates are historically very problematic because different systems have different rules around how to format dates.  Both JavaScript and Microsoft format dates differently which can lead to problems.


Joe Brinkman
DNN Corp.
 
New Post
3/20/2012 4:19 PM
 
Hi Joe

That's a point, why the heck am I using a server side control for this! Anyway I'm wanting to do this client side of course and bundle all the data into one post for the big push. OK I'll have a look at datepicker right now.

Yes I've tried debugging. The issue is definately to do with the wrong type or wrong values (i.e. NULL being returned). I've been given a gizillion code examples and nothing seems to be working out.

Values are being delivered like this:

 var _request = {
                requestUri: _serviceURL + "/myTable",
                method: "POST",
                data: _postData
            };


Other type values such as strings and integers work just fine.

"Both JavaScript and Microsoft format dates differently which can lead to problems."


Exactly right, generally brain hemorrhage!

I'm wondering if anybody has any specific examples on how they've managed to post dates to SQL Server via knockout.


Alex Shirley


 
New Post
3/20/2012 4:26 PM
 
Whoops I forgot to say thanks for the response Joe!


Alex Shirley


 
New Post
3/20/2012 4:39 PM
 

Alex,

  I'll whip up a Jsfiddle here in a bit with a working date example which should help you get started.


Joe Brinkman
DNN Corp.
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Getting StartedGetting StartedKnockoutJS, DNN, SQL Server and datesKnockoutJS, DNN, SQL Server and dates


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out