@ symbol in Email field is causing problem at runtime in MVC3.0
The email textbox is getting filled by ä valid email id (say patra.bikash@gmail.com) from database at run time. Thus I am getting run time JS error (Dynamic file) that gmail is not defined. (in MVC 3.0) Any idea how to solve this?
If it would ve compile time, then I could have double prefixed with @ to avoid this problem, bu开发者_开发问答t how can I tackle it at runtime? In the below code @contacts.EmailAddress is fetching patra.bikash@gmail.com from my ViewModel.
<tbody id="BillingContactRows">
@{
if (Model.ContactList != null && Model.ContactList.Count > 0)
{
foreach (Models.Contact contacts in Model.ContactList)
{
<tr>
<td>
@if (contacts.Primary)
{
<input type="radio" id="rdo.@contacts.ContactID" value="radio" checked="checked" name="contact" onclick=" SelectContact('@contacts.ContactID');" />
}
else
{
<input type="radio" id="rdo.@contacts.ContactID" value="radio" name="contact" onclick=" SelectContact('@contacts.ContactID');" />
}
</td>
<td>
@contacts.ContactName
</td>
<td>
@contacts.EmailAddress
</td>
<td>
<span class="datatype3">
@contacts.Status
</span>
</td>
</tr>
}
}
}
</tbody>
According to the HTML specification;
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
This means, in short, that you can't use the @ symbol for the id of the radio buttons.
I suggest that you create a helper method that you can call to translate the @ symbol to another - perhaps underscore - symbol
精彩评论