Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add id HTML attribute in ASP.NET MVC w/ VB.NET

I am trying to add an ID HTML attribute to a form using ASP.NET MVC and VB.NET

<%Html.BeginForm("Create", "Model", "", "", New With {.id = "CreateForm"})%>

This gives me a type error, since .id is expecting an Integer, not a string. How do add an ID attribute to my form?

like image 777
CoolGravatar Avatar asked May 07 '09 17:05

CoolGravatar


2 Answers

I believe you need something like this

<%  Html.BeginForm("Create", "Model", 
    FormMethod.Post, New With {.id = "CreateForm"})%>    

I think it's trying to cast one of your empty strings as the FormMethod enumeration, which won't cast correctly.

Either way check this link out, it has all the overloads for the BeginForm method.

Html.BeginForm

like image 62
Joseph Avatar answered Oct 26 '22 13:10

Joseph


Close:

<%Html.BeginForm("Create", "Model", "", "", new {id = "CreateForm"})%>
like image 40
Jordan S. Jones Avatar answered Oct 26 '22 14:10

Jordan S. Jones