HTML bug for Opinion tag.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
NopCommerce uses the next code in many places

 
//_ProductAttributes.cshtml
<option selected="@attributeValue.IsPreSelected" value="@attributeValue.Id">@attributeName</option>
//_AddressAttributes.cshtml
<option selected="@attributeValue.IsPreSelected" value="@attributeValue.Id">@attributeValue.Name</option>
...


and we'll see the next wrong html code after rendering

<option selected="true" value="1">Color Black</option>
<option selected="false" value="2">Color Green</option>
or
<option selected="" value="2">Color Green</option>


The correct html code has another syntax

<option selected value="1">Color Black</option>
<option value="2">Color Green</option>

The correct xhtml code has another syntax

<option selected='selected' value="1">Color Black</option>
<option value="2">Color Green</option>


Description about Tag option.
https://www.w3schools.com/tags/att_option_selected.asp

This bug is an several places. Look for this string <option selected="

Correct code (example)
@foreach (var attributeValue in attribute.Values)
{
    var selectedvalue=attributeValue.IsPreSelected?"selected":"";
   // or var selectedvalue=attributeValue.IsPreSelected?"selected = \"selected\"":"";
    <text>
    <option @selectedvalue value="@attributeValue.Id">@attributeValue.Name</option>
    </text>
}
7 years ago
foxnetsoft wrote:
...and we'll see the next wrong html code after rendering

<option selected="true" value="1">Color Black</option>
<option selected="false" value="2">Color Green</option>
or
<option selected="" value="2">Color Green</option>

But ASP.NET knows how to handle such cases. That's why we use it. For example, please see this demo page. It doesn't have selected="true" or selected="false" or selected=""
7 years ago
Yes... I am sorry, you are right.
My customer showed this problem for extra customer's address fields...
Maybe he used changed .cshtml file.

I am sorry for this investigation.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.