Home > Mobile >  How do I receive the input to my form in my asp.net action?
How do I receive the input to my form in my asp.net action?

Time:10-12

this seems super simple, yet I'm having trouble figuring it out. I have a asp.net core mvc application, and I need to use a form to send some input to a specific action.

I have this form:

                    <div class="panel-body">
                        <form action="@Url.Action("updateStatus", "Home")">
                            <textarea class="greyback" id="w3review" name="w3review" rows="4" cols="50"> Update your status...
                            </textarea>
                            <br><br>
                            <input class="input" type="submit" value="Submit">
                        </form>
                    </div>

The form invokes the action that I want it to, so far so good, but I of course also need the text that is put into the textfield to be sent along, and that I'm having a bit of trouble with.

I have tried looking at the special razor page stuff for making forms that look like so:

@using  (Html.BeginForm(“action”,   “controller”))

But I don't quite understand how that works, how I can hold onto my css tags, or how I could actually create a textarea tag with this syntax.

What would be the best way to send along this data to the action that I want?

CodePudding user response:

how I could actually create a textarea tag with this syntax.

You can use the following code:

@Html.TextArea("w3review", "Update your status...", new { @class = "greyback" })

result: enter image description here

What would be the best way to send along this data to the action that I want?

There is no difference to use html tags or htmlhelper.Htmlhelper will be rendered to html code which is the same with using html tags directly.

  • Related