I'm building dynamic forms based on a partial view. My view inherits a model with a single property: CatalogName { get; set; }
.
I have tried this:
@Html.Label(Model.CatalogName + "-ProductNumber", "Product Number")
@Html.TextBox(Model.CatalogName + "-ProductNumber")
The HTML renders like this though:
<label for>Product Number</label>
<input name="CatatalogName-ProductNumber" type="text" />
If I write my code like this:
@Html.Label("ProductNumber-" + Model.CatalogName", "Product Number")
It will render the way I expect
<label for="ProductNumber-CatalogName">Product Number</label>
Is this a bug with MVC? Are there any answers as to why my concatenation won't work the way I want it to in the label, but works fine with the TextBox?
My model looks like this:
public class Product
{
public string CatalogName { get; set; }
}
My partial view inherits the model:
@model Models.Product
My controller renders an action result like this:
return PartialView("_webForm", Models.Product { CatalogName = "CatalogName"} );
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…