vendredi 28 août 2015

Passing RadioButton Value to Controller within bootstrap

I am trying to pass a radiobutton value to a controller. However I cannot seem to figure out how to get the value I pass through. I am not sure what to do with the controller.

Model that I use to keep the value

public class PendingTasksModel
{
    public string environmentName { get; set; }
}

View

<div class="col-md-3">
    <div class="btn-group-vertical pull-right" data-toggle="buttons">
         <label class="btn btn-primary" style="@displayOak">
             @Html.RadioButtonFor(model => model.environmentName, "OAK")
             OAK
         </label>
         <label class="btn btn-primary" style="@displayQa">
             @Html.RadioButtonFor(model => model.environmentName, "QA")
             QA
         </label>
         <label class="btn btn-primary" style="@displayProd">
             @Html.RadioButtonFor(model => model.environmentName, "PROD")
             PROD
         </label>
     </div>
 </div>

Controller

private ActionResult InitializeService(string option)
    {
        _binding = new BasicHttpBinding();
        if (option == "OAK")
        {
            _endpointAddress = new EndpointAddress(ConfigurationManager.AppSettings["OAK"]);
        }
        else if (option == "PROD")
        {
            _binding.Security.Mode = BasicHttpSecurityMode.Transport;
            _endpointAddress = new EndpointAddress(ConfigurationManager.AppSettings["PROD"]);
        }
        else
        {
            _binding.Security.Mode = BasicHttpSecurityMode.Transport;
            _endpointAddress = new EndpointAddress(ConfigurationManager.AppSettings["QA"]);
        }
        _channel = new ChannelFactory<IEisIntegrationService>(_binding, _endpointAddress);

        try
        {
            _target = _channel.CreateChannel();


        }
        catch
        {
            if (_target != null)
            {
                ((ICommunicationObject)_target).Abort();
            }
        }
        return View();
    }

Aucun commentaire:

Enregistrer un commentaire