Search code examples
html.netasp.net-mvcrazorresx

Simple text does not render properly in a html input tag from resx file


In resx file I have an entry:

AccountRegisterSubmit = Create a new account

In my View:

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

    <div>
        <input type="submit" [email protected] />
    </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?


Solution

  • 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>