0

как из input передать параметры в функцию?я хочу взять из input value и передать в функцию как параметр, как это сделать?

<form method="post" action=" ">
    <input type = "hidden" name = "PhoneID" value = "@ViewBag.Id" />
    <table>
        <tbody>
            <tr>
                <td>Name</td>
                <td><input asp-form = "Name" type = "text" name = "Name" /></td>
            </tr>
            <tr>
                <td>Producer</td>
                <td><input asp-form = "Producer" type = "text" name = "Producer" /></td>
            </tr>
            <tr>
                <td>ShortDescription</td>
                <td><input asp-form = "ShortDescription" type = "text" name = "ShortDescription" /> <td>
            </tr>
            <tr>
                <td>Price</td>
                <td><input asp-form = "Price" type = "text" name = "Price" /> <td>
            </tr>
            <tr>
                <td colspan = "2"><input type = "submit" value = "Update" /></td>
            </tr>
        </tbody>
    </table>
</form>


[HttpPost]
        public string Update(string Name, string Producer)
        {
            _phoneRepository.Update(string Name, string Producer);
            return "Updated";
        }
0

1 ответ 1

0

У вас опечатка в вызове метода Update.

[HttpPost]
public string Update(string Name, string Producer)
{
     _phoneRepository.Update(Name, Producer);
    return "Updated";
}

В остальном Ваш пример должен быть вполне работоспособен. Во всяком случае, в одной из статей используется нечто подобное.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.