0

I have a scenario which requires the admin user to identify a number of parameters at the back end and let end user to input value for these parameters, sending back.

I am wondering is there any solution to this kind of scenario? My guess, java script would be required.

Thank you.

1 Answer 1

1

You need to make a HTML Form. A form will be rendered to the user, and when the user submits the form, the entered information will be sent back to the server.

This page is a decent tutorial on how to make a HTML form using ASP.NET MVC.

You have to create a model (class) with the properties you want the user to submit.

public class MyModel
{
    public Int32 RandomNumber { get; set; }
}

Then, you will create two MVC actions. One, for requesting the form page, which will return a ViewResult with an empty model. The other will be the submit action, and will require a parameter with the model. This will be sent via the user's submission of the form:

public class FooController : Controller
{
    [HttpGet]
    public void Create()
    {
        return this.View("~/Views/FooController/Create.cshtml", new MyModel() );
    }
    [HttpGet]
    public void Create(MyModel model)
    {
        //Do something with model information, such as save to database
    }
}

The ViewResult will need to return a CSHTML page that creates a form for this model.

@model MyModel

@using(Html.BeginForm("Create", "Foo", FormMethod.Post))
{
    @Html.TextBoxFor( m => m.RandomNumber )
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you James, I will have a look and go through the tutorial.

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.