Skip to main content

How To Call An Action In a Controller From A dropdown change event

By Using MVC4 ,JQuery,And Nhibernate

sample Code



//Script Block
    $(function () {
        $("#resourceSelectList").change(function () {
            var urlAction = "~/Planner/LoadPlannerWithFilter?value=";
            var value = $(this).val();

    
        });
    });


@*HTML Markup*@

 @Html.DropDownListFor(x => x.resourceSelectList, Model.resourceSelectList)
 
 
And Cotroller Part
 

        public ActionResult PlannerLanding()
        {
            WrapperClass wrp = new WrapperClass();
            var resourceSelectList = obj.getResourceList()
                                        .Select(x => new SelectListItem
                                        {
                                            Value = x.Owner,
                                            Text = x.Owner
                                        });
            wrp.resourceSelectList = new SelectList(resourceSelectList, 
   "Value", "Text");
            return View(wrp);
        }

/*
*This action method is getting called when the drop down value changes.  
*/

        public ActionResult LoadPlannerWithFilter(string value)
        {
            WrapperClass wrp = new WrapperClass();
            var resourceSelectList = obj.getResourceList()
                                        .Select(x => new SelectListItem
                                        {
                                            Value = x.Owner,
                                            Text = x.Owner
                                        });
            wrp.resourceSelectList = new SelectList(resourceSelectList, 
              "Value", "Text");
            return View("PlannerLanding",wrp);
        }  

Comments

Popular posts from this blog

NHibernate QueryOver Class And Projection....

Introduction The ICriteria API is NHibernate's implementation of Query Object . NHibernate 3.0 introduces the QueryOver api, which combines the use of Extension Methods and Lambda Expressions (both new in .Net 3.5) to provide a statically typesafe wrapper round the ICriteria API. QueryOver uses Lambda Expressions to provide some extra syntax to remove the 'magic strings' from your ICriteria queries. So, for example: .Add(Expression.Eq("Name", "Smith")) becomes: .Where<Person>(p => p.Name == "Smith") With this kind of syntax there are no 'magic strings', and refactoring tools like 'Find All References', and 'Refactor->Rename' work perfectly. Note: QueryOver is intended to remove the references to 'magic strings' from the ICriteria API while maintaining it's opaqueness. It is not a LINQ provider; NHibernate 3.0 has a built-in ...

Function pass by value vs. pass by reference

Function pass by value vs. pass by reference I will call what you are passing in a to a function the actual parameters, and where you receive them, the parameters in the function, the formal parameters. They are also called actual and formal arguments. When passing parameters, what it is called and what happens can be confusing. It is less essential that you call it the "correct" thing than you know exactly what is happening. It is critical to have a good mental model, a valid memory picture of the process. Recall that when you call a function, a chunk of memory called an activation record is allocated. Critical to the discussion here is that this memory holds the formal parameter values and function local variables. By definition, pass by value means you are making a copy in memory of the actual parameter's value that is passed in, a copy of the contents of the actual parameter. Use pass by value when when you are only "using" the paramet...

The Core Concepts of Angular -- Jithin CJ

I started to learn angular from 2016, I was very curious about the celibacy of this super hero. From my initial understanding is like, the power of angular is only limited on " html decoration "  But this JavaScript framework has the potential to re-define conventional html-css patterns . Modern browsers support for things like modules, classes, lambdas, generators, etc. These features fundamentally transform the JavaScript programming experience. But big changes aren't constrained merely to JavaScript. Web Components are on the horizon. The term Web Components usually refers to a collection of four related W3C specifications: Custom Elements - Enables the extension of HTML through custom tags.  HTML Imports - Enables packaging of various resources (HTML, CSS, JS, etc.).  Template Element - Enables the inclusion of inert HTML in a document.  Shadow DOM - Enables encapsulation of DOM and CSS.  Developers can create fully encapsulated (Shadow D...