Geeks With Blogs

Bob Palmer's Developer Blog .NET, SQL, and Silverlight Development

If you're using both JQuery and MVC, odds are you're going to want to easily reference your form elements by ID.  To handle this using the built in HTML form helper class, you will need to use some of the parameters.

For example, if I have a controller named 'Message', with an action named 'AddTopic' and want to create an HTML form that executes a Post with an ID and Name both of 'posttopic', I would use the following code snippet:

<%

using (Html.BeginForm("AddTopic", "Message", FormMethod.Post, new { id = "posttopic", name = "posttopic" }))

 Enjoy!

{%>

Posted on Saturday, January 23, 2010 5:21 PM | Back to top


Comments on this post: Adding an ID property to an HTML form in MVC

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © BobPalmer | Powered by: GeeksWithBlogs.net