html.beginform

Html.BeginForm() with only form Id is not generating correct action url

試著忘記壹切 提交于 2019-12-07 06:13:48
问题 I only want to add the formId in the beginForm() If i try using Html.BeginForm(null, null, FormMethod.Post, new {@id="Id"}) then the Html generated is <form action="/newquestion/payment/b9f88f80-f31f-4144-9066-55384c9f1cfc" ... > i don't know how that action url is generated so i tried, Html.BeginForm(new {@id="Id"}) but then the action url looks like this <form action="/newquestion/payment/Id... > In both the cases the action url is not what it should be and it is not hitting the post action

Html.BeginForm() with only form Id is not generating correct action url

时光怂恿深爱的人放手 提交于 2019-12-05 11:15:56
I only want to add the formId in the beginForm() If i try using Html.BeginForm(null, null, FormMethod.Post, new {@id="Id"}) then the Html generated is <form action="/newquestion/payment/b9f88f80-f31f-4144-9066-55384c9f1cfc" ... > i don't know how that action url is generated so i tried, Html.BeginForm(new {@id="Id"}) but then the action url looks like this <form action="/newquestion/payment/Id... > In both the cases the action url is not what it should be and it is not hitting the post action of the controller. When you are trying to generate a route, such as with BeginForm , MVC will do its

How do I add data- attributes to Html.BeginForm

醉酒当歌 提交于 2019-12-03 14:33:35
问题 I use the following to create a form to upload images on a mobile site. @using (Html.BeginForm("Form/", "Quote", FormMethod.Post, new { enctype = "multipart/form-data" })) However as it is using jQuery mobile, I have enabled Ajax so that transition between pages is nice and smooth. This has caused the problem that my form won't upload the images as you cannot do file uploads with ajax. I need to add the attribute data-ajax="false" to this form in order for it to allow my file uploads. Does

How do I get the QueryString values into a the RouteValueDictionary using Html.BeginForm()?

时间秒杀一切 提交于 2019-12-02 07:29:01
I've found that Html.BeginForm() automatically populates the routeValueDictionary with the RawUrl (ie. QueryStringParamters). However I need to specify an HtmlAttribute so I need to use the override... public static MvcForm BeginForm(this HtmlHelper htmlHelper, string actionName, string controllerName, FormMethod method, object htmlAttributes) When I do the QueryString values are NOT automatically added to the RouteValueDictionary. How can I accomplish this? Here is my best attempt but it doesn't seem to be working. <% RouteValueDictionary routeValueDictionary = new RouteValueDictionary

send a ViewModel which contains a list with a Html.BeginForm (MVC 4)

余生颓废 提交于 2019-12-01 20:26:03
问题 My viewmodel contains a integer list, the problem I have is that when I send my modified form viewmodel, it is always equal to null. My ViewModel : public class testViewModel { public List<int> itemTest { get; set; } Action in my Controller : For example, I'll try to sum ​​the new values ​​entered into the form, but the sum calculated is always equal to 0, nothing changes. public ActionResult form(int nbre) { testViewModel montest = new testViewModel() { itemTest = new List<int>() }; for(int

Adding dynamic parameters with Html.BeginForm and jQuery submit

自作多情 提交于 2019-11-30 16:25:14
// html <% using (Html.BeginForm("MyAction", "MyController", new { id = ViewContext.RouteData.Values["id"] }, FormMethod.Post, new { enctype = "multipart/form-data", class="myForm" })) { %> <input type="file" name="blah" /> <% } %> // script $container.find('.myButton').click(function() { $container.find('.myForm').submit(); }); Before the form is submitted, I need to add some extra parameters (route values) which can only be calculated at the time of submit. How do I do that? You could append a hidden field to the form before submitting it: $container.find('.myButton').click(function() { var

Using Html.BeginForm with querystring

有些话、适合烂在心里 提交于 2019-11-30 14:29:14
问题 My url looks like this: customer/login?ReturnUrl=home In the login view, I have used this pattern of code which works fine. @using(Html.BeginForm()) { ... } This magically generates following html <form action="customer/login?ReturnUrl=home" method="post"> But now, I need to add an attribute (e.g., data-id="something" ) in the form. How can I do that? If I don't have any query string, I know I can do something like this: @using(Html.BeginForm(action, controller, FormMethod.Post, new { data_id

rolling my own @Html.BeginfBrm()

六月ゝ 毕业季﹏ 提交于 2019-11-30 14:08:53
问题 I am writing a custom validation set that will display all missing elements on a div. I'd like to be able to use a custom @Html.BeginForm() method that will write out that div but I'm really not sure where to even begin as this nut is a little tougher to crack than just a html extension that writes out a Tag or String (the form encapsulates data/controls and is closed by } at the end). I looked at the metadata version of the built in BeginForm() method and it wasn't much help to me.

Using Html.BeginForm with querystring

☆樱花仙子☆ 提交于 2019-11-30 10:50:16
My url looks like this: customer/login?ReturnUrl=home In the login view, I have used this pattern of code which works fine. @using(Html.BeginForm()) { ... } This magically generates following html <form action="customer/login?ReturnUrl=home" method="post"> But now, I need to add an attribute (e.g., data-id="something" ) in the form. How can I do that? If I don't have any query string, I know I can do something like this: @using(Html.BeginForm(action, controller, FormMethod.Post, new { data_id="something" })) But don't know how to add querystring which should be in html: <form action="customer

rolling my own @Html.BeginfBrm()

扶醉桌前 提交于 2019-11-30 09:34:01
I am writing a custom validation set that will display all missing elements on a div. I'd like to be able to use a custom @Html.BeginForm() method that will write out that div but I'm really not sure where to even begin as this nut is a little tougher to crack than just a html extension that writes out a Tag or String (the form encapsulates data/controls and is closed by } at the end). I looked at the metadata version of the built in BeginForm() method and it wasn't much help to me. Essentially, I just want to extend that method if possible and have it write out a MvcHtmlString of a div that