.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

MVC, jQuery, and Data Types

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net

Hello, and thanks for reading!

I have an MVC web site that serves up REST-style web services to a jQuery front-end.  My question is about the "proper" way of passing certain types of data between the server and the client, especially when it comes to XML or complex .NET data types.

Regarding XML, is there a way to pass "pure" XML, or do you simply always pass XML data as a string?  I'm thinking here of the return type on my MVC action... right now I leave the jQuery $.ajax() method at its default content-type, and my MVC method's return type is string, but I wasn't sure if there was a better way.

And then you get into complex .NET data types such as DataSet.  Obviouisly jQuery won't be able to process a DataSet object as-is but I wasn't sure if .NET provided a way to translate a DataSet into a more universal datatype, such as XML or JSON.

Any suggestions would be great :)


View Complete Post

More Related Resource Links

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.

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

Frequently Asked Questions - SQL Server Data Types

This is good and precise introduction and Frequently Asked Questions - SQL Server Data Types

Posting data to ASMX and return Object for jQuery


I am using fluent NHibernate with WebForms and I am trying to build a page where I allow a user to post a status update on their profile page and I a using a .asmx WebService to post the data to the database and then returnig a StatusUpdate instance to the page to be used by jQuery. I have a couple problems.

1) First off when I return a string from the WebService(i was testing) the textbox where the user enters their status doesnt empty the contents. And since the page doesnt refresh even if I manally clear out the textbox and put in something else, it still posts the previous status to the database again. How do I fix this?

2) Secondly, when I return the StatusUpdate Object from the Webservice I cant the results to display anything. Like I sad, Im using jQuery to make an AJX call to the WebService.

Here is my code:

User Profile Page:

Status: <asp:Label ID="status" runat="server"></asp:Label><span style="font-size:.7em;"><asp:Label ID="statustime" runat="server"></asp:Label></span><br />
<textarea id="statusBox" rows="3" cols="40"></textarea><br />
<input type="button" value="Update Status" onclick="SetStatus(); return false;

Writing Data to database with jQuery Forms, ASMX Webservice, & JSON - help!



Can someone point me in the right direction on how to submit data from a jQuery form to a ASMX webservice? I have gotten everything on the form ready to be submitted to the database and now I am stuck on how to send it over using $.ajax(). Everything I have read tells me how to get data from a webservice and display it with jQuery, but not the other direction nor how to access the json data within the within the webservice service(similar to a Request.Form approach with ASP.NET forms).

In other words: 

1. What do I need to do to my webservice to make sure it can receive data from the jQuery form. 

2. What do I need to do in jQuery to receive an acknowledgement the save on the server side was successful. 

I can explain more if need be, but if there is a comprehensive tutorial on not only reading, but also WRITING data with jQuery, JSON, etc. I would love to get pointed in that direction. 

insert the data in database using gridview jquery



I want to use gridview and bind the data and after i want insert the data in database using jquery,

below the link i got for delete


but i want the sample example for insert  row from gridivew and add the database.




Hello People,

               Well i am just trying to test interoperability between ASP.net And Java web services, wanted to know what are the INTEROPERABILITY issues concering DATA TYPES that are there between the 2?...any thoughts? 

MERGE using jQuery with a WCF Data Service

I'm a bit new to the whole asp.net thing so this is probably a silly question, but here it goes: I have created a WCF Data service based based on a ADO.net Entity--it's very basic: namespace raid{ public class allPeopleDataService : DataService< raid.raidEntities > { public static void InitializeService(DataServiceConfiguration config) { config.SetEntitySetAccessRule("*", EntitySetRights.All); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2; } }} I've been successfully retrieving data using jquery's '$.getJSON' and inserting data using a modified $.ajax: $.ajax({url: "/allPeopleDataService.svc/lists",dataType: 'json',contentType: 'application/json',data: $jsonObj,processData: false,type: 'POST'}); I was reading the post at http://msdn.microsoft.com/en-us/library/cc668771.aspx and trying to use the MERGE method to update parts of the data with the following jquery jsont = { "__metadata": { "uri": "/allPeopleDataService.svc/lists(1)", "type":"raidModel.list" }, "list_name": "list blah blah" }; $.ajax({ url: "/allPeopleDataService.svc/lists(1)", dataType: 'json',

Global Variables and data types

Hi, I have a small issue with the datatype problems. This is what my scenario is. I have a global variable "Qtr" declared as "Int32" datatype. Next, i have a ActiveXscript with VBScript Language. With the below piece of code. All it does, it will calculate and assign the calculated value to the global variable "Qtr". But due to some datatype conversion problem it is not displaying the Calculated value. It is showing null. But the value in the local variable is getting displayed. Can anyone figure out what the problem is all about. I have the option of taking the String datatype for the global variable but in the next step in the workflow , we have an stored procedure call i.e. an execute sql task where we will be call a stored procedure EXEC sp ? where the parameter datatype is an INT in the database. That is why i am finding problem.  I have used the work around i.e. using SSIS advanced expressions and avoided the parameter mapping and all. Function Main() 'msgbox("test") Dim Qtr Dim currentYear 'Constants qYears = 3 Qtr= (currentYear - qYears) * 10 + 4 msgbox(Qtr) msgbox("Assigning the value to the variable") DTSGlobalVariables("Qstart").Value =  Cint(Qtr) msgbox("Display Value in the variable") MsgBox(DTSGlobalVariables("Qtr").Value)      End Function Can a

Storing multiple data types in a class?

I need help writing a class that will contain three values per item.  I'll be passing parameters to a report: Parameter Name, Data type (int, string, date, etc), and Value. When I pass those values to the report using the class they should be in original form (i.e. an integer should be a numeric, a string should be a string, etc.).  I can do it converting the data's value to strings on one end, and reconverting to the original data type on the other, which seems like a lot of runaround. Is there a simple way?  Also, if I'm able to store & retrieve the data in it's native format I don't need the "Data type" stored. Any help or tips will be appreciated.

The data types varchar and date are incompatible in the add operator

On the following query I keep getting the error 'The data types varchar and date are incompatible in the add operator'.  As you can see I have tried to convert the date but doesn't seem to work.  The variable @Date1 will start off as a date.  Any suggestions? ' declare @Date1 date declare @SQL1 varchar(2000) set @Date1 = convert(varchar, cast(getdate() as date), 102) set @SQL1 = 'select * from tbl_1 where convert(varchar,cast(tbl_1.Current_dt as date),102) = '+@Date1+'' print @SQL1    LISA86


Hi Folks, I downloaded SQL 2008 and installed recently.Everything perfectly works except one thing that I can't use VARCHAR AND CHAR data types anymore.I was using SQL 2005 and I had the same problem there as well. Please helpe to solve this problem

Analysis Services Using Oracle as a Data Source Data Types mismatch System.Int32 and System.Int64

Hi everyone, I searched for this issue but there is only 4 questions about it in this forum from 2007 I hope that someone can help me. Im usign SASS 2008 using a Oracle as a datasource.  I already have my fact tables linked with dimensions, lets say, FACTID System.Int64 with DIMENSIONID System.Int64 (My dimensions are replaced by named querys and work perfectly) I add a new table to my DSV and the NEWDIMENSIONID looks like System.Int64, but at the moment I replace the table with a named query (I have to use Oracle quering) the NEWDIMENSIONID changes to System.Int32 .  After that I cant relate the fact table with the dimension table. Actions: Looked for the columns that relate from Oracle... both are NUMBER(5). Looked for the differences between my other tables that are already related as System.Int64 and there is not a single difference between the ones that works and the one who doesnt. Solutions Ive tried and didnt work: 1. Cast the column as SQL query didnt work it send an error.  Looks kind of obvious because we are quering Oracle... but I had to try.  CAST( X AS BIGINT) 2. Cast the column as Oracle query . TO_NUMBER 3. Do it inside the server using the Analysis Services Enterprise insted of my Analysis Services Developer. Same issue.   Any ideas? suggestions?   Please? Thank you very much ;) Sincerly Adriana L. PS. At the begging of

jQuery & WCF Data Service - PUT Update - Rejected with 405 Method Not Allowed

I am writing a sample jQuery/WCF Data Service app to utilize OData, however I am getting a status code 405 - Method not allowed when I attempt to update an entity with a PUT Http method. I have configured my WCF Data Service as follows: public static void InitializeService(DataServiceConfiguration config) { config.SetEntitySetAccessRule("jCredentials_PINs", EntitySetRights.All); config.SetEntitySetAccessRule("jCredentials_PINTree", EntitySetRights.All); //config.SetServiceOperationAccessRule("MyServiceOperation", ServiceOperationRights.All); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2; } I am attempting to update the jCredentials_PINs table. My jQuery call to update the WCF Data Service is as follows:function UpdatePIN(selectedTreeNode, updateObj) { var url = dataService + "/jCredentials_PINs(guid'" + selectedTreeNode.get_value() + "')"; var json = JSON.stringify(updateObj); $.ajax({ url: url, data: json, type: "PUT", contentType: "application/json; charset=utf-8", timeout: 10000, dataType: "json", success: AjaxPINUpdateSuccess, error: AjaxPINUpdateFailure }); } function AjaxPINUpdateSu

Which is the best approach for applying business rules and basic validation like data types?

Hi Everybody   Please suggest me the best approach for applying the business rules and data type validations .Here is my choices : 1)Sequential work flow 2)State machine work flow 3)Work flow rule engine 4)Rule engine without workflow Out of above choices ,which is the best approach? Please provide me the reasons or senarioes for which is the best approach for applying the business rules and also performancewise. My requirement is : After getting the reports ,need to apply the datatype validations like valid or invalid date ...etc to the reports .And stored into Database.In the next step,need to apply the business rules to that reports in such a way that data should be good quality. Thank you very much

SSIS User Defined Data Type (Alias Data Types) and OLE DB Command validation

Hello everyone, I've been having an issue with trying to run my SSIS package on a server, and it seems to be failing on the OLE DB Command step.  What we have in our SQL 2005 DB, is a User-Defined Data Type (base type char(7)) and the OLE DB Command is supposed to call a proc that passes in a value of this data type. ie:  CREATE PROCEDURE myProcedure ( @passedInFromSSIS MY_DATATYPE ) AS .... In my SSIS package, I have the type defined as DT_STR with a length of 7.  Now, when I run the package locally (via Visual Studio), the process runs with success.  However, once the package is deployed on a server and run from an application (note: it is run under a different user), the process fails on a validation step with a "Invalid Parameter Number" error. Now, if I change the input parameter in my proc to the base type of the user-defined data type, the process works again. Has anybody run into a similar issue or know what may be causing this issue?  I first suspected perhaps I needed to grant permissions on the user-defined data type (since I was able to run it under my security context, but not under the application's), however noticed that there isn't security tied to the types.  Any other thoughts?  Please let me know if you need further explanation.  Thanks!

how to open a subform model Form,Sub Window form using jquery that save the data ajex

how to open a subform model Form,Sub Window  form using jquery that save the data ajex
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