Html-Code.RadioButton setzt alle Werte auf ausgewählten Wert

Nach basteln um zu lösen [diesem][1] problem ist, ich denke der Kern des Problems ist die folgende:

Wenn Sie die Html.RadioButton() html-helper-mit einem Enum-Wert-Feld, können Sie nur wählen Sie die option einmal. Nach der Umbuchung der Seite, die Helfer ignorieren, den Wert in den Aufruf und alle radio-buttons den gleichen Wert, wird der Wert, den Sie ausgewählt vorherigen post zurück.
Mache ich etwas falsch?

Beispiel (sehen Sie das Wert der Tasten)

<fieldset>
    <legend>Test</legend>                            
    <div>
        <label for="SearchBag.EffectIndicatorAny" id="EffectIndicatorAnyLabel">
            Any
        </label>                
        <%=Html.RadioButton("SearchBag.EffectIndicator", "Any" , ViewData.Model.SearchBag.EffectIndicatorIsAny, new { @id = "SearchBag.EffectIndicatorAny" })%>
    </div>
    <div>
        <label for="SearchBag.EffectIndicatorSolid" id="EffectIndicatorSolidLabel">
            Solid
        </label>                
        <%=Html.RadioButton("SearchBag.EffectIndicator", "Solid", ViewData.Model.SearchBag.EffectIndicatorIsSolid, new { @id = "SearchBag.EffectIndicatorSolid" })%>
    </div>
    <div>
        <label for="SearchBag.EffectIndicatorEffect" id="EffectIndicatorEffectLabel">
            Effect
        </label>                
        <%=Html.RadioButton("SearchBag.EffectIndicator", "Effect", ViewData.Model.SearchBag.EffectIndicatorIsEffect, new { @id = "SearchBag.EffectIndicatorEffect" })%>
    </div>
</fieldset>

Generiert

<fieldset>
    <legend>Effect</legend>                            
    <div class="horizontalRadio">
        <label for="SearchBag.EffectIndicatorAny" id="EffectIndicatorAnyLabel">
            Any                                      
        </label>                
        <input checked="checked" id="SearchBag.EffectIndicatorAny" name="SearchBag.EffectIndicator" type="radio" value="Any" />
    </div>
    <div class="horizontalRadio">
        <label for="SearchBag.EffectIndicatorSolid" id="EffectIndicatorSolidLabel">
            Solid
        </label>                
        <input id="SearchBag.EffectIndicatorSolid" name="SearchBag.EffectIndicator" type="radio" value="Solid" />
    </div>
    <div class="horizontalRadio">
        <label for="SearchBag.EffectIndicatorEffect" id="EffectIndicatorEffectLabel">
            Effect
        </label>                
        <input id="SearchBag.EffectIndicatorEffect" name="SearchBag.EffectIndicator" type="radio" value="Effect" />
    </div>
</fieldset>

Wird und generiert das zweite mal:

<fieldset>
    <legend>Effect</legend>                            
    <div class="horizontalRadio">
        <label for="SearchBag.EffectIndicatorAny" id="EffectIndicatorAnyLabel">
            Any                                      
        </label>                
        <input id="SearchBag.EffectIndicatorAny" name="SearchBag.EffectIndicator" type="radio" value="Solid" />
    </div>
    <div class="horizontalRadio">
        <label for="SearchBag.EffectIndicatorSolid" id="EffectIndicatorSolidLabel">
            Solid
        </label>                
        <input checked="checked" id="SearchBag.EffectIndicatorSolid" name="SearchBag.EffectIndicator" type="radio" value="Solid" />
    </div>
    <div class="horizontalRadio">
        <label for="SearchBag.EffectIndicatorEffect" id="EffectIndicatorEffectLabel">
            Effect
        </label>                
        <input id="SearchBag.EffectIndicatorEffect" name="SearchBag.EffectIndicator" type="radio" value="Solid" />
    </div>
</fieldset>
Schreibe einen Kommentar