如何添加ID HTML属性在ASP.NET MVC瓦特/ VB.NET [英] How to add id HTML attribute in ASP.NET MVC w/ VB.NET

查看:156
本文介绍了如何添加ID HTML属性在ASP.NET MVC瓦特/ VB.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试添加使用ASP.NET MVC和VB.NET的ID HTML属性的表单

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"})%>

这给了我一个类型的错误,因为.ID期待一个整数,而不是字符串。如何做一个ID属性添加到我的形式?

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

推荐答案

我相信你需要像这样

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

我认为这是试图投你的空字符串作为FormMethod枚举,这将无法正常投中的一个。

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

无论哪种方式,检查此链接了,它对于BeginForm方法的所有重载。

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

Html.BeginForm

这篇关于如何添加ID HTML属性在ASP.NET MVC瓦特/ VB.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆