DmitryEfimenko / TwitterBootstrapMvc

Fluent implementation of ASP.NET-MVC HTML helpers for Twitter Bootstrap.
Apache License 2.0
222 stars 79 forks source link

RouteName on Form #324

Closed dcraigen closed 10 years ago

dcraigen commented 10 years ago

It would be nice to be able to specify a RouteName on a Form similar to the ActionLink Helpers.

Any chance or am I missing a method somewhere?

DAn

gicalle commented 10 years ago

something like this?

@using (var f = Html.Bootstrap().Begin(new Form().RouteValues(new { ... })))
DmitryEfimenko commented 10 years ago

I've checked currently available overloads on MVC's BeginForm() method. None of them have "routename" as a parameter. So I'm not sure how I'd implement it since BMVC uses regular MVC's methods under the hood.

dcraigen commented 10 years ago

In MVC you would use Html.BeginRouteForm("RouteName")

On 18 August 2014 04:15, Dmitry A. Efimenko notifications@github.com wrote:

I've checked currently available overloads on MVC's BeginForm() method. None of them have "routename" as a parameter. So I'm not sure how I'd implement it since BMVC uses regular MVC's methods under the hood.

— Reply to this email directly or view it on GitHub https://github.com/DmitryEfimenko/TwitterBootstrapMvc/issues/324#issuecomment-52447004 .

DmitryEfimenko commented 10 years ago

Indeed I've never found myself in the situation when I'd need to use it, therefore the lack of knowledge about it. Is there a significant benefit of using it compare to the regular BeginForm()? I'd rather avoid implementing it because it would not be as simple as sticking an extension method on the BMVC's Form class. Also, you are the first one to ask about it.

dcraigen commented 10 years ago

I use friendly route names for some of my pages for SEO purposes, the standard stuff like actions is all great as I can specify RouteName() but for forms, when the form is posted using the current form methods it loses the URL in the address bar and replaces it with the default route, not a problem for my SEO as this is never indexed but just makes the URL's look ugly as they are using Guid's for my Id's.

On 18 August 2014 06:02, Dmitry A. Efimenko notifications@github.com wrote:

Indeed I've never found myself in the situation when I'd need to use it, therefore the lack of knowledge about it. Is there a significant benefit of using it compare to the regular BeginForm()? I'd rather avoid implementing it because it would not be as simple as sticking an extension method on the BMVC's Form class. Also, you are the first one to ask about it.

— Reply to this email directly or view it on GitHub https://github.com/DmitryEfimenko/TwitterBootstrapMvc/issues/324#issuecomment-52452436 .

DmitryEfimenko commented 10 years ago

as far as I know, the parameters of the POST form do not end up in the url. They are in the request body. Could you show me an example of a form that you have?

dcraigen commented 10 years ago

Would it be possible to have a .RouteName(string routeName) on the Form which just overwrites the action. The MVC BeginRouteForm just uses UrlHelper.GenerateUrl with the route name to set the action.

On 18 August 2014 06:09, Daniel Craigen dan@craigen.net wrote:

I use friendly route names for some of my pages for SEO purposes, the standard stuff like actions is all great as I can specify RouteName() but for forms, when the form is posted using the current form methods it loses the URL in the address bar and replaces it with the default route, not a problem for my SEO as this is never indexed but just makes the URL's look ugly as they are using Guid's for my Id's.

On 18 August 2014 06:02, Dmitry A. Efimenko notifications@github.com wrote:

Indeed I've never found myself in the situation when I'd need to use it, therefore the lack of knowledge about it. Is there a significant benefit of using it compare to the regular BeginForm()? I'd rather avoid implementing it because it would not be as simple as sticking an extension method on the BMVC's Form class. Also, you are the first one to ask about it.

— Reply to this email directly or view it on GitHub https://github.com/DmitryEfimenko/TwitterBootstrapMvc/issues/324#issuecomment-52452436 .

DmitryEfimenko commented 10 years ago

This is done. Please get latest and let me know if it works all fine for you