Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free.

I'd like to use AngularJS for databinding but I also want to keep a Send button that will submit the form sending the model (which the controller will change to a c sharp object) without ajax. I know I have the model in the $scope and that it is in json format, but it seems that the only way to send it to an Action is via Ajax and not by submitting the entire form.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

When binding the data using AngularJS if you specify the name attribute, the action method in C# should receive the values.

For example, <input type='text' name='userName' value={{userName}} />

When user clicks the submit button, the server site method should receive the value if you have a variable named userName.

share|improve this answer
    
Hello Shahed! I'm talking about an Object here. Like an object "Order" that has OrderItems. The name of the text field for an order item will be something like order_orderItem_0_product, order_orderItem_1_product. If I use angular, how can I specify the name to be like that? –  Shak Smith Feb 14 '14 at 22:07
    
Hi Shak, If you like to have the name in specific format, you could bind that too using Angular. For example, name='{{x.propertyName}}' value={{x.value}} Then, on server side these values can be accessed from the "FormCollection collection" parameter. –  Shahed Feb 14 '14 at 22:37
    
I didn't think about that. Thanks Shahed! –  Shak Smith Feb 17 '14 at 13:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.