Frage

In resx file I have an entry:

AccountRegisterSubmit = Create a new account

In my View:

@{
    ViewBag.Submit = @Resources.AccountRegisterSubmit;
}

    <div>
        <input type="submit" value=@ViewBag.Submit />
    </div>

HTML resulting is malformed

<input type="submit" value="Create" a="" new="" account="">

I need instead

<input type="submit" value="Create a new account">

Any idea what could be wrong?

War es hilfreich?

Lösung

You are missing the quotes in the HTML input tag:

<input type="submit" value="@ViewBag.Submit" />

The @ symbol will print out the value as-is, without quotes, so you currently end up with:

<input type="submit" value=Create a new account>

Andere Tipps

You need to double quote the value so that it is treated as text

   <input type="submit" value="@ViewBag.Submit" />
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top