Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

js object to c# object

// Construct a object in JS

var obj = {
  id: 0 ,
  userName: 'Bill'
};

// C# class:

public class myClass
{
  public int id;
  public string userName;
}

// Then for example using AJAX send your data to C#,
// and deserialize, when you need work with object

$.ajax({
	type: "POST",
  	// Note that you need to pass the method as url
	url: '<your server url>' + 'DeserializeObject',
  	// your data is the object you want to send
	data: obj,
	contentType: "application/text; charset=utf-8",
	dataType: "text"
})

[HttpPost]
public void DeserializeObject(string objJson)
{
var obj = (new JavascriptSerializer()).Deserialize<myClass>(objJson);
}
Comment

c# to javascript object

// 1st c# code to json
https://csharp2json.io/

// then convert json to object 
https://www.convertsimple.com/convert-json-to-javascript/
Comment

PREVIOUS NEXT
Code Example
Javascript :: axios 400 bad request 
Javascript :: react native add react native vector icons not working 
Javascript :: javascript addeventlistener pass parameters 
Javascript :: infinite loop example 
Javascript :: Image resize using html and javascript 
Javascript :: document.getelementsbyname 
Javascript :: typescript compile string to js 
Javascript :: sliding puzzle javascript 
Javascript :: find the largest array from an array in javascript 
Javascript :: nodemon exclude 
Javascript :: javascript closest parent 
Javascript :: react moment calendar times 
Javascript :: three js html 
Javascript :: trigger a change is 
Javascript :: make custom draggable in react 
Javascript :: .map method 
Javascript :: javascript even number 
Javascript :: javascript extend object 
Javascript :: error: Unknown dialect undefined 
Javascript :: what is my version of linux mint 
Javascript :: react usememo hook 
Javascript :: use promise in angular 8 
Javascript :: get date format javascript 
Javascript :: oops in js 
Javascript :: crud operation react js 
Javascript :: json object in html page 
Javascript :: how to write a scope in rails 
Javascript :: array index javascript 
Javascript :: google js console 
Javascript :: javascript get 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =