Html.BeginForm with html attributes asp.net mvc4

前端 未结 4 412
难免孤独
难免孤独 2021-01-03 21:21

I have Edit Action with Html.BeginForm. How can I add HTML attributes?

I know only one way:

@using (Html.BeginForm(\"Edit\", \"Clients\"         


        
4条回答
  •  攒了一身酷
    2021-01-03 22:18

    If this might be helpful for some people, this works for me:

    @using (Html.BeginForm("RefreshData", "Home", FormMethod.Post, 
            new { Id = "timerangeId", @name = "timerange" }))
        {
            // form elements and input
        }
    

    In Javascript:

    document.getElementById("timerangeId").submit();
    

提交回复
热议问题