I'm trying to hook into Google Analytics and have this:
@using (Html.BeginForm("Register", "Account", FormMethod.Post,
new { id = "account-register-form",
onsubmit = "_gaq.push(['_link', 'someurl'])" }))
My rendered view then looks like this:
<form action="/Account/Register/Basic" id="account-register-form" method="post"
onsubmit="_gaq.push(['_link', 'someurl'])">
I have tried Html.Raw("_gaq.push(['_link', 'someurl'])") but this does not work, because I think BeginForm does the encoding.
Code works fine if don't turn off encoding but you can turn off attribute encoding by creating a class like this:
public class HtmlAttributeEncodingNot : System.Web.Util.HttpEncoder
{
protected override void HtmlAttributeEncode(string value, System.IO.TextWriter output)
{
output.Write(value);
}
}
and adding this to web.config under :
<httpRuntime encoderType="HtmlAttributeEncodingNot"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With