Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Dean 13 posts 123 karma points
    Mar 23, 2023 @ 09:12
    Dean
    0

    Pass value from form to method

    Hi there everyone (love the fact of it being the friendliest community 🙂)

    Very new with Umbraco and have come across a scenario which I think should be easy for someone here.

    I have created a view (could also be a partial in other scenarios). For simplicity I have a text box and a button.

    My code

    @using(Html.BeginUmbracoForm<HelloWorld>("Greet", FormMethod.Post))
    {
    <Input type="text">
    <Button type="submit">Submit</button>
    }
    
    My controller has the method
    
    Public void Greet(string Name)
    ....
    ....
    

    Even I click the button, the parameter Name is always empty? How could I pass that value from the textbox with a button click?

  • J 447 posts 864 karma points
    Mar 23, 2023 @ 09:47
    J
    1

    Dean

    You could try and add name="Name" to your input type. This way you should see the value in debug mode.

Please Sign in or register to post replies

Write your reply to:

Draft