lundi 5 juin 2017

Simple Razor C# .Net form: Checkboxes and Session Variable settings

First, I want to explain I do not know any Razor or C#. I have a client that I build out high-fidelity prototyping for. Some of the elements are getting kind of advanced where JavaScript is not working for me anymore.

The Ask:

I have a modal that I trigger (using bootstrap), this modal has some checkboxes in a form. Each checkbox will trigger to turn on or turn off a session that will turn certain elements on or off on a series of 5-6 pages. Here I am just working with one of those sessions. I can duplicate once I figure this out. Any help will be greatly appreciated.

Code:

@{

if (Request.Form["fitscorechecked"] != null && Request.Form["fitscorechecked"] == "on") {
    Session["fitscore"] = "on";

} else {
    Session["fitscore"] = "off";
}
}

My Form:

    <form method="post">
            <div class="row">
                <div class="col-sm-12 bottom5"><input type="checkbox" id="fitscorechecked" name="fitscorechecked" value="true"/> &nbsp;&nbsp; Show fit score during adjustment</div>
                <div class="col-sm-12 bottom5"><input type="checkbox" id="Anonymous" name="Anonymous" value="true" /> &nbsp;&nbsp; Make contributors anonymous</div>
                <div class="col-sm-12 bottom5" data-toggle="tooltip" data-html="true" title="<h5>Advanced Options</h5><h6>Will allow you to view related tasks, manually adjust patterns (power users only), and the ability to download responses.</h6>">
                    <input type="checkbox" id="Advanced" name="Advanced" value="true" /> &nbsp;&nbsp; Show advanced options</div>
            </div>
            <div class="prototype-btngroup-center">
               <a class="btn btn-default prototype-btn-spacersm" data-dismiss="modal">Cancel</a>
               <a class="btn btn-primary" type="submit" value="submit" href="#stepAlign6" data-toggle="tab" data-step="5" data-dismiss="modal">Begin Alignment</a>
            </div>  
            </form> 
<form>

I have never built a form in .net so I am really lost. I just need something very simple that does not use controllers. Much of this code is show and then redone based on the updates from the product team, so something that is simple and easy to adjust.




Aucun commentaire:

Enregistrer un commentaire