mercredi 12 mai 2021

Assigning a value by checking a box in razor pages

I`m making a web app for online exams and after i write the question and the answers, i want to select the right answer by checking a checkbox. [The right answer][1] will have the same value as the checked answer but i do not know how to make it appear in the [question list][2] or in the [database][3].

Model variables:

public string question{get;set;}
public string asnwer1{get;set;}
public string answer2{get;set;}
public string answer3{get;set;}
public string answer4{get;set;}
public string rightanswer{get;set;}

Create question page cshtml:

Intrebare = Question | Optiune = Answer | Raspuns = Right Answer.

<div class="form-group">
            <label asp-for="AplicatieIntrebare.Intrebare" class="control-label"></label>
            <input asp-for="AplicatieIntrebare.Intrebare" class="form-control" />
            <span asp-validation-for="AplicatieIntrebare.Intrebare" class="text-danger"></span>
        </div>
        <div class="form-group">
            <label asp-for="AplicatieIntrebare.Optiune1" class="control-label"></label>
            <input asp-for="AplicatieIntrebare.Optiune1" class="form-control" />
            <span asp-validation-for="AplicatieIntrebare.Optiune1" class="text-danger"></span>
            <input id="Checkbox1"  type="checkbox" />
        </div>
        <div class="form-group">
            <label asp-for="AplicatieIntrebare.Optiune2" class="control-label"></label>
            <input asp-for="AplicatieIntrebare.Optiune2" class="form-control" />
            <span asp-validation-for="AplicatieIntrebare.Optiune2" class="text-danger"></span>
            <input id="Checkbox2" type="checkbox" />
        </div>
        <div class="form-group">
            <label asp-for="AplicatieIntrebare.Optiune3" class="control-label"></label>
            <input asp-for="AplicatieIntrebare.Optiune3" class="form-control" />
            <span asp-validation-for="AplicatieIntrebare.Optiune3" class="text-danger"></span>
            <input id="Checkbox3" type="checkbox" />
        </div>
        <div class="form-group">
            <label asp-for="AplicatieIntrebare.Optiune4" class="control-label"></label>
            <input asp-for="AplicatieIntrebare.Optiune4" class="form-control" />
            <span asp-validation-for="AplicatieIntrebare.Optiune4" class="text-danger"></span>
            <input id="Checkbox4" type="checkbox" />
        </div>

Thank you! [1]:https://i.stack.imgur.com/MRUqr.png [2]:https://i.stack.imgur.com/sgnst.png [3]:https://i.stack.imgur.com/ztIIc.png




Aucun commentaire:

Enregistrer un commentaire