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 Introduction

 NHibernate NHibernate is an open source Object-Relational Mapping (ORM) tool for the .Net platform… and the existing documentation and tutorials that I could find, whilst plentiful, are not aimed at those new to or inexperienced with ORM. This tutorial is based on using Visual Studio (I used 2008 beta 2) and Sql Server, however the database used is almost immaterial (one of the advantages of using an OR mapper). If you already know what NHibernate and ORM are and you want to use it but just need to know how?  Otherwise, read on. WTF is ORM? There is plenty of good stuff out there on what Object-Relational Mapping is, try wikipedia or the intro here (the tutorial is a bit out of date but the explanation is good) or there’s always Google . However, in a nutshell, ORM is the process of mapping business objects (think OOP) to database relations (read tables). An OR Mapper is a tool that manages this process. There are several different OR Mappers available for ...

Computer Science Defenition

Computer Science Computer science is the scientific and practical approach to computation and its applications. It is the systematic study of the feasibility, structure, expression, and mechanization of the methodical procedures (or algorithms ) that underlie the acquisition, representation, processing, storage, communication of, and access to information , whether such information is encoded as bits in a computer memory or transcribed in genes and protein structures in a biological cell . [1] A computer scientist specializes in the theory of computation and the design of computational system

Machine learning in a Nutshell

you start with the data that contains patterns. you can feed that data to the machine learning algorithm (may be more algorithms) to find the patterns in the data .This algorithm generates something called a model.Model functionality is to recognizes the patterns then presented with the new data. Application supplies new data to see if it matches known patterns such as the data about new transactions. The model can determine the probability whether the transaction is fraudulent or not, it knows that because of the patterns.      Machine learning lets us find patterns in existing data, then create and use a model that recognizes those patterns in new data Machine learning has gone mainstream - big vendors think there's big money in this market      Machine learning can probably help your organization.