[CLOSED] RadioFor always False

  1. #1

    [CLOSED] RadioFor always False

    I set up 3 radio buttons but never get true value for selected radio,please help.

    View

    @model ERP_test.Controllers.radiogroup
    @{
        var X=Html.X();
    }
    @X.ResourceManager()
    
    @(X.FormPanel().ID("f")
    .Items
    (
    
                        X.FieldContainer().AnchorHorizontal("100%").Layout(LayoutType.HBox)
                        .Items
                        (
    
    
    
                            X.RadioFor(obj => obj.radio1)
                            .Name("PF")
                            ,
                           X.RadioFor(obj => obj.radio2)
                           .Name("PF")
                            ,
                            X.RadioFor(obj => obj.radio3)
                           .Name("PF")
                            
                        )
                       
                 
    
                 )
                 .Buttons
                 (
    
                 X.Button()
            .Text("Save")
            .ID("btnSave")
           
    
            .DirectEvents(de =>
            {
              
                de.Click.FormID = "f";
                de.Click.Action = "save";
               
            })
    
                 )
                 )
    Controller
    public class RadioForController : Controller
        {
            //
            // GET: /RadioFor/
    
            public ActionResult Index()
            {
                return View();
            }
            public void save(radiogroup _radiogroup)
            {
    
            }
    
        }
        public class radiogroup
        {
            public bool radio1 { get; set; }
            public bool radio2 { get; set; }
            public bool radio3 { get; set; }
        }
    Last edited by Daniil; Oct 03, 2014 at 1:42 PM. Reason: [CLOSED]
  2. #2
    Hi @matrixwebtech,

    You should use a ModelBinder.
    http://forums.ext.net/showthread.php...l=1#post105622
  3. #3
    Hi,
    I am not clear what I have to do exactly for radio button,but I found if I remove
    .Name("PF")
    and code like bellow

    X.RadioFor(obj => obj.radio1)
                            .Listeners(l =>
                            {
                                l.Change.Handler = @"if(this.getValue()==true)
                                                    App.radio2.setValue(false);
                                                    App.radio3.setValue(false);
                                                    ";
                            })
    
    
                            ,
                           X.RadioFor(obj => obj.radio2)
                           .Listeners(l =>
                            {
                                l.Change.Handler = @"if(this.getValue()==true)
                                                    App.radio1.setValue(false);
                                                    App.radio3.setValue(false);
                                                    ";
                            })
    
                            ,
                            X.RadioFor(obj => obj.radio3)
                            .Listeners(l =>
                            {
                                l.Change.Handler = @"if(this.getValue()==true)
                                                    App.radio1.setValue(false);
                                                    App.radio2.setValue(false);
                                                    ";
                               
                            })
    Its works,but I face a problem,some time I have to click twice to select a radio,most of time for radio3
    property then its working fine .any suggestion
    Last edited by matrixwebtech; Sep 26, 2014 at 11:34 AM.
  4. #4
    I guess the problem is that the Change event probably fires on each .setValue() call.

    Well, I would not recommend you to organize a radio group in this way. I think your initial solution is better.

Similar Threads

  1. [CLOSED] Sample code for RadioFor and MultiComboFor in MVC Razor
    By MTSI in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 06, 2013, 6:03 AM
  2. IsUpload = false IE
    By threewonders in forum 1.x Help
    Replies: 7
    Last Post: Oct 11, 2011, 11:36 AM
  3. Set button visible to false
    By glenh in forum 1.x Help
    Replies: 2
    Last Post: Aug 24, 2009, 10:44 AM
  4. Replies: 0
    Last Post: Jun 25, 2009, 11:52 AM
  5. [CLOSED] border false
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Feb 11, 2009, 2:08 AM

Posting Permissions