forms - @Url.Action in ASP.NET MVC to action formaction? -


i've spent of day chasing tail on this. there many wonderful suggestions out there, none address problems:

we have existing website, someone's linked button href's absolute addresses, , trying figure out way that. i've got of it, 1 line styled button , formaction won't work. original code this:

@using(html.beginform(null,null,formmethod.post)) {    // ... <div>, stack of buttons, i've converted    // <a href="@url.action(.... , buttons work     <button class="submit" id="save" value="save" formaction="model/action" class="btn btn-primary"><span class="glyphicon glyphicon-floppy-save"></span></button>      // ... stack of more buttons , checkboxes, working... }... 

i need retain glyphicon button image, , formaction when button clicked.

if change button <input>, lose <span> , hence glyphicon.

if call @url.action() in button, this:

<button type="submit" onclick="location.href='@url.action("action","model")'" class="btn.... etc. 

it doesn't seem submit in post. if specify action , model in beginform(), resource not found, because it's trying find view, instead of action...

so, is proper way change button absolute link asp.net mvc something, fire action in controller and stylable button glyphicon image?

the issue because of formaction="model/action" attribute on submit button. attribute used point different controller , action, 1 defined in html.beginform() method. useful if have multiple submit buttons in same form, should submit different actions.

in case, there no controller , action defined in html.beginform() method, formaction attribute should point controller action accepts argument matching type of model. right now, points "model/action". http 404 error, because either don't have controller called modelcontroller, or controller doesn't have action called action. change controller or action part of formaction attribute point correct controller or action.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -