htmlextensions

Using a strongly typed ActionLink when the action method doesn't take a primitive type

血红的双手。 提交于 2019-12-24 16:33:41
问题 Does anyone know how I could go about doing something like : Html.ActionLink(c => c.SomeAction(new MessageObject { Id = 1 } )) This should output a link with the url of "/Controller/SomeAction/1", pointing at an ActionMethod along the lines of: public Controller : Controller { public ActionResult SomeMethod(MessageObject message) { // do something with the message return View(); } } I've written something similar for generating forms, but that doens't need to include the Id value on the end

MVC 3 htmlhelper extension method to wrap around content

懵懂的女人 提交于 2019-12-08 23:24:25
问题 I searched but could not find any quick solutions for an MVC 3 htmlhelper to create a wrapper method. What I'm looking for is something like: @html.createLink("caption", "url") { <html> content in tags </html> } the result should have <a href="url" title="Caption"> <html> content in tags </html> </a> Any help with this. 回答1: The way that this is done with BeginForm is that the return type MvcForm impliments IDisposable so that when used within a using statement, the Dispose method of MvcForm

MVC 3 htmlhelper extension method to wrap around content

落爺英雄遲暮 提交于 2019-11-30 08:17:11
I searched but could not find any quick solutions for an MVC 3 htmlhelper to create a wrapper method. What I'm looking for is something like: @html.createLink("caption", "url") { <html> content in tags </html> } the result should have <a href="url" title="Caption"> <html> content in tags </html> </a> Any help with this. Jamie Dixon The way that this is done with BeginForm is that the return type MvcForm impliments IDisposable so that when used within a using statement, the Dispose method of MvcForm writes out the closing </form> tag. You can write an extension method that does exactly the same