.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

DataContractJsonSerializer changing my date

Posted By:      Posted Date: September 01, 2010    Points: 0   Category :ASP.Net
A user enters a date in a form, but when I pass the date through an AJAX json call, my date is getting changed by the DataContractJsonSerializer. Here's my AJAX call:function Save(){ //Convert date to milliseconds from from 1/1/1970 - necessary for passing a date through JSON var d = "09/01/2010 05:00"; myDate = new Date(d); myTicks = myDate.getTime(); var message = { MessageID: $("#MessageID").val(), MessageDate: '\/Date(' + myTicks + ')\/', }; $.ajax({ url: "<%= Url.Action("SaveMessage") %>", type: "POST", dataType: "json", data: $.toJSON(message), contentType: "application/json; charset=utf-8", success: function(result) { if (result && result.success) { // } } }); } Here's my serialization code:public override void OnActionExecuting(ActionExecutingContext filterContext){ if ((filterContext.HttpContext.Request.ContentType ?? string.Empty).Contains("application/json")) { var serializer = new DataContractJsonSerializer(RootType); filterContext.ActionParameters[Param] = serializer.ReadObject(filterContext.HttpContext.Request.InputStream); }} It's changing my dates to GMT. So if the user ente

View Complete Post

More Related Resource Links

DataContractJsonSerializer: Problem when deserializing the Date

Sorry for cross-posting. I posted the same question on the Silverlight forum, but it has not received a single answer yet. The majority of folks there must be more interested in UI than in more fundamental stuff.     Hello everyone! Let's say we have the folllowing POCO classes: public class PocoObject : List<PocoPropertyData> {     public PocoObject() {}     public override string ToString()     {         var parts = new List<string>();         foreach (var pd in this)             parts.Add(string.Format("{{N=[{0}], Type=[{1}], V=[{2}]}}", pd.N, pd.V == null ? typeof(object) : pd.V.GetType(),  pd.V));         return string.Join(",", parts);     } } public class PocoPropertyData {     public string N { get; set; }  // the property name     public object V { get; set; }  // the property value } As you can see, the PocoPropertyData can hold value of any type. When I execute the following code in both .NET 4 application and Silverlight 4 application: ========================================================= var poco = new PocoObject {       { new PocoPropertyData { N = "DateTimeField", V =  Da

Changing Date format in Filter toolbar


i have added a toolbar to a Data View Web Part and enabled the Filter option. When i click on the filter, the Due Date field displays choices as Saturday, September 11, 2010. Within the DWVP I have the format set to mm/dd/yyyy, the differening formats seem to prevent the filter from working. How I can change the format in the filter dropdown ?

Thanks in advance

Dean MCTS-SQL 2005 Business Intelligence

Date not changing when selection changes in asp.net calendar

Date either changes ramdomly or does not change at all. I find the ajax calendar extender a little hard to work with. Thanks.
Partial Class Default2
    Inherits System.Web.UI.Page

    Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim datebox As New TextBox
        Dim calendar1 As New Calendar
        datebox = CType(DetailsView1.FindControl("datebox"), TextBox)
        datebox.Text = calendar1.SelectedDate.ToShortDateString()
    End Sub
End Class

        <asp:DetailsView ID="DetailsView1" runat="server" Height="207px" Width="342px" DataSourceID="AccessDatasource"
            AutoGenerateEditButton="True" AutoGenerateDeleteButton="True" 
            AutoGenerateRows="False" AutoGenerateInsertButton="True" 
                <asp:TemplateField HeaderText="PODate" SortExpression="POdate">
                     <asp:TextBox ID="datebox" runat="server" Text='<

Changing Default Language for British Date Format




After reading several topics about Datetime formats from US-English to British, I got more confused.  I have successfully changed Default Language on my local machine's SQL Server Express using this:

EXEC sp_configure 'default language', '23' 

But I can't change it on a Server side.  It prompts me to run 'RECONFIGURE' again and when I do I am getting this error:

"Address Windowing Extensions (AWE) is not supported in this edition of SQL Server."


Changing DatePicker Date Label of 15

To change the label of the date picker control in WPF is very easy. When you drag and drop the date picker control from the toolbox then it will show 15 as default, It will be nice to show current day is comfortable to show the current date.Image 1 shows the default date picker control when you drag and drop it from the toolbox here you can see that it display 15 which we want to change to show the current date.

Changing Date Format.




Currently I am using a shared sql server from My Hosting provider to send and receive some Data Fom my VB application. and as I am not an administrator i cant change the language. Even i can't access any sql properties.


but i want to change date format to dd-mm-yyyy instead of mm-dd-yyyy


Changing the graphics on the home page of a SharePoint site

When you create a site in Microsoft Windows SharePoint Services by using the default Team Site template, the home page includes two default graphics. A Windows SharePoint Services graphic appears in the body of the page, and a picture of a house in a circle appears near the site title. You can change these graphics to customize your site. Changing the smaller graphic requires a Windows SharePoint Services compatible Web page editor

Using a CompareValidator to check input is a valid date

The CompareValidator can do more than just compare two controls. You can also compare it against several of the main .net data types such as Date, Integer, Double and Currency.

To do this you would set Operator="DataTypeCheck" and instead of setting the ControlToCompare or ValueToCompare attributes as you normally would you use the Type="Date" (or any of the data types I have listed above).

How To Set a Date Format In GridView Using ASP.NET 2.0

A very common desire is to set a column of a gridview to display just the month, day and year of a DateTime type. The problem is the by default, the HtmlEncode property of the boundfield attribute (
The problem is that if this field is enabled, you can not pass format information to the boundfield control. That is, if you try the following code, you will not get the desired result.

jQuery Date picker Implementation in ASP.NET

I've posted a wrapper ASP.NET around the jQuery.UI Datepickercontrol. This small client side calendar control is compact, looks nice and is very easy to use and I've added it some time back to my control library.

This is primarily an update for the jQuery.ui version, and so I spend a few hours or so cleaning it up which wasn't as easy as it could have been since the API has changed quite drastically from Marc's original implementation. The biggest changes have to do with the theming integration and the resulting explosion of related resources.

If you want to use this component you can check it out a sample and the code here:

How to format datetime & date with century?

Execute the following Microsoft SQL Server T-SQL datetime, date and time formatting scripts in Management Studio Query Editor to demonstrate the usage of the multitude of temporal data formats available and the application of date / datetime functions.


Date and Time Functions in SQLSERVER

Date and time functions allow you to manipulate columns and variables with DATETIME and SMALLDATETIME data types.

1 DATEPART Function
2 DATENAME Function
3 DAY, MONTH, and YEAR Functions
5 DATEADD Functions
6 DATEDIFF Function
7 More SQL Server Functions

Data Types - Date and Time in SqlServer

Date and time values can be stored with either the DATETIME or SMALLDATETIME data type. The difference between the two is that SMALLDATETIME supports a smaller range of dates and does not give the same level of precision when accounting for time. The DATETIME data type can hold values from January 1st of 1753 to December 31st of 9999. The time is stored to the 1 three hundredths of a second and each value takes up 8 bytes of storage. The SMALLDATETIME data type can hold values between January 1st 1900 and June 6th of 2079. The time is tracked to the minute and each value takes up 4 bytes of storage. The majority of business applications can live happily with SMALLDATETIME, however, if you are in an environment where each second matters or you need to make estimates to the distant future (or past) then you have to resort to DATETIME. If you fail to specify the time when inserting a value into a DATETIME or SMALLDATETIME column, a default of midnight is used. If you fail to specify the date portion the default of January 1, 1900 is used.

Built-in Functions - Date and Time Functions

Date and time functions allow you to manipulate columns and variables with DATETIME and SMALLDATETIME data types.

Essential SQL Server Date, Time and DateTime Functions

The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any formatting considerations at all.

Date/Time Conversions Using SQL Server

There are many instances when dates and times don't show up at your doorstep in the format you'd like it to be, nor does the output of a query fit the needs of the people viewing it. One option is to format the data in the application itself. Another option is to use the built-in functions SQL Server provides to format the date string for you.

Date and Time Data Types and Functions

The following sections in this topic provide an overview of all Transact-SQL date and time data types and functions. For information and examples that are common to date and time data types and functions
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend