簡體   English   中英

聲明性輔助方法中的 Html.BeginForm()

[英]Html.BeginForm() in declarative helper methods

我試圖創建一個from使用Html.BeginForm()在剃刀輔助方法,在partial page (Razor)app_code文件夾中。 但沒有成功。

@helper  GenerateForm(...){

 @using(@Html.BeginForm(.... // error

}

我嘗試添加System.web.mvcsystem.web.webpages類的命名空間,但沒有區別。 是否可以在此代碼中使用此方法

您應該將 HtmlHelper html 傳遞給這個助手並使用它:

helper  GenerateForm(HtmlHelper html, ...){

    @using(html.BeginForm(.... // error

}

試試這個:@using(Html.BeginForm(...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM