1

I dynamically change DOM on client-side to add some new input fields using JavaScript.

Can I obtain the data on the server-side without using Ajax? Just pushing send button and get this new data in my controller?

3 Answers 3

3

ANSWER IS HERE: http://habrahabr.ru/blogs/aspnet_mvc/88766/, Don't pay attention to language, look code samples

Sign up to request clarification or add additional context in comments.

Comments

1

If you're posting the form, sure. You can use either the FormCollection to get the element you want, or explicitly identify the parameter in your method signature. Assume you added an input element with the name "myTextBox", you could do the following:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(int id, string myTextBox, FormCollection collection) {

  // better
  if (myTextBox != null) {
    // do something with the string
  }

  // good
  if (collection["myTextBox"] != null) {
    string textboxvalue = collection["myTextBox"].ToString();
  }

}

Comments

1

You need to add "name" attribute to the control, so the data will be sent to the server on form submit.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.