TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
TC Serdar Şengül
NA
5
1.3k
How do I send the form datas 2 classes?
Sep 12 2014 3:23 PM
hi my friend my english is not good.. I hope you can understand me.
I have a form but I want to send data to 2 class thank you..
public
class
ContractItem
{
public
string
Name
{
get
;
set
;
}
public
string
LastName
{
get
;
set
;
}
}
public
class
PaymentItem
{
public
int
PaymentSalary
{
get
;
set
;
}
public
date
SalaryDate
{
get
;
set
;
}
}
example html
Form
<
form name
=
"Ajaxform"
method
=
"POST"
>
Name
:
mike
Last
Name
:
anderson
Salary
:
100
$
Date
:
10
/
01
/
2014
</
form
>
function
AjaxForm
(
form
,
action
)
{
temp
=
$
(
"form"
).
serializeArray
();
var
SendData
=
{};
AddContract
(
SendData
);
}
function
AddContract
(
data
)
{
//( data = mike,anderson,100,10/01/2014 ( 4 data comes successfully )
var
status
=
false
;
$
.
ajax
(
{
url
:
'Contract/AddContract'
,
type
:
"POST"
,
data
:
JSON
.
stringify
({
item
:
data
}),
contentType
:
'application/json; charset=utf-8'
,
dataType
:
'json'
,
async
:
false
,
success
:
function
(
Id
)
{
},
error
:
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
}
});
}
HttpPost
]
public
JsonResult
AddContract
(
ContractItem
)
{
bool
Status
=
false
;
return
Json
(
Status
,
JsonRequestBehavior
.
AllowGet
);
}
public
JsonResult
AddContract
(
ContractItem
)
(
If
I use
this
code
,
only mike
,
anderson data comes successfully
)
public
JsonResult
AddContract
(
PaymentItem
)
(
and
If
I use
this
code
,
only
100
,
10
/
01
/
2014
data comes successfully
)
How do I merge data? or How do I make dynamic inheritance?
example
ContractItem : PaymentItem
I tried to use a tuple, but it did not work
public
JsonResult
AddContract
(
Tuple
<
ContractItem
,
PaymentItem
>
item
)
Reply
Answers (
4
)
how to get configured values from log4net.config / app.confi
Radio Button