我試圖掛接到谷歌Analytics(分析),並有unencode屬性是:如何調用Html.BeginForm
@using (Html.BeginForm("Register", "Account", FormMethod.Post,
new { id = "account-register-form",
onsubmit = "_gaq.push(['_link', 'someurl'])" }))
我的渲染視圖則是這樣的:
<form action="/Account/Register/Basic" id="account-register-form" method="post"
onsubmit="_gaq.push(['_link', 'someurl'])">
我曾嘗試Html.Raw(「_ gaq.push(['_ link','someurl'])」)但這不起作用,因爲我認爲BeginForm會執行編碼。
我從來沒有測試過它是否會起作用。不知道這是有效的。但是因爲這看起來令人討厭,我現在感覺很骯髒;) – adriaanp
@adriaanp,你會期望MVC助手產生無效標記嗎? –
我想不是,我會按原樣離開它。 – adriaanp