Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
500
AutoPostBack on selected index changed of igCombo w/o Ajax
posted

Is there any way other than Ajax request to autopostback the form when the selectd index of a combobox is changed?

I dont want to perform ajax requests to call the methods explicitly, Isnt there an onchange() attribute which will post the form(this.form.submit()) when the index is changed without clicking the submit button.

Also in my igCombo I cannot define it like this :

THIS DOESNT WORK:

@using (Html.BeginForm())
{
@(Html.Infragistics().Combo("comboProducts") // When I supply it with id, I get object not set to an instance of an object exception
)

}

THIS WORKS:

@using (Html.BeginForm())
{

@(Html.Infragistics().Combo()    //This works but I think the ID of / <select> element is not set , rather / <span> gets the id. 
.InputName("comboProducts") 
.ID("comboProducts")               //is this the same id which gets supplied to .Combo("id")?? 

) }

 --------------------------------------------------

Because of this issue, I think I am also unable to persist the selected value of igCombo on postback.

Please help me out here.

Parents
  • 29417
    Verified Answer
    Offline posted

    Hello Omer ,

     

    Thank you for posting in our forum.

     

    I’ve tested how the editor behaves when the id is set as follows:  @(Html.Infragistics().Combo("combo1") …

    However I didn’t get any errors when testing this on my side.

     

    In general the combo does have events you can use to trigger a submit. For example you can use the DropdownClosed event and in it force the form to submit:

        $(document).delegate("#combo1", "igcombodropdownclosed", function (evt, ui) {

                $("form")[0].submit();

            });

     

    Then on the Action associated with the form you can get the  passed value from by passing a variable with the same name in the Action:

    public ActionResult SaveData(string combo1)

            {

     

     

     

    If you need to persist the selection over postbacks I recommend that you associate the Combo with a property from your Model.

    For example :  @(Html.Infragistics().ComboFor(a => a.SelectedValue)

     

    Then on the Action triggered on submit you can return the same view and in the model pass the value for the current Selected Value:

     

      public ActionResult SaveData(string SelectedValue)

            {

                igCombo_example_form.Models.ComboModel model = new igCombo_example_form.Models.ComboModel();

                List<Product> prod = new List<Product>();

                for (int i = 0; i < 20; i++)

                {

                    prod.Add(new Product() { ID = i, ProductName = "Prod Name" + i });

                }

                model.Products = prod;

                model.SelectedValue = SelectedValue;

     

                return View("Index",model);

            }

     

    I’ve attached a sample for your reference. Please refer to it and let me know if you have any questions.

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer II

    Infragistics, Inc.

    http://es.infragistics.com/support

     

    igCombo_example_form.zip
Reply Children