I have a grid column with checkboxes and I want to give them a different id. Id is based on the CustomerId in the Model. What syntax should I use to concatenate the [email protected].
// using the telerik grid  id="[email protected]"  // does not work    // this will put the value of @item.Customernumber as the checkbox id
columns.Template(@<text><input type='checkbox' id="@item.Customernumber" name="@item.CustomerNumber" value="@item.OrderNumber" /></text>).Width(50)   second option:
columns.Template(@<text><input type='checkbox' id="[email protected]" name="@item.CustomerNumber" value="@item.OrderNumber" /></text>).Width(50)   the above will render as
<input type="checkbox" id="[email protected]" value=... />  
                Just add the id property to the html-attributes. That will override the default id generated by the editorfor-helper-methode.
Razor has no ties to ASP.NET MVC because Razor is a general-purpose templating engine. You can use it anywhere to generate output like HTML. It's just that ASP.NET MVC has implemented a view engine that allows us to use Razor inside of an MVC application to produce HTML.
The @ symbol is used in Razor initiate code, and tell the compiler where to start interpreting code, instead of just return the contents of the file as text. Using a single character for this separation, results in cleaner, compact code which is easier to read.
[email protected] will not work because razor thinks of it as of an e-mail, you need to do it like this instead: chk_@(item.OrderNumber)
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