Click here to Skip to main content
15,886,110 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: trouble sending message to the view from controller Pin
Hamiltonian1331-May-17 9:16
Hamiltonian1331-May-17 9:16 
GeneralRe: trouble sending message to the view from controller Pin
John C Rayan31-May-17 22:17
professionalJohn C Rayan31-May-17 22:17 
GeneralRe: trouble sending message to the view from controller Pin
F-ES Sitecore1-Jun-17 0:41
professionalF-ES Sitecore1-Jun-17 0:41 
GeneralRe: trouble sending message to the view from controller Pin
John C Rayan1-Jun-17 22:05
professionalJohn C Rayan1-Jun-17 22:05 
GeneralRe: trouble sending message to the view from controller Pin
Hamiltonian139-Jun-17 6:28
Hamiltonian139-Jun-17 6:28 
GeneralRe: trouble sending message to the view from controller Pin
John C Rayan16-Jun-17 2:48
professionalJohn C Rayan16-Jun-17 2:48 
Questionadd small delete button or image to the options of select Pin
indian14326-May-17 13:51
indian14326-May-17 13:51 
QuestionNeed some help in implementing Partial View Pin
indian14323-May-17 13:44
indian14323-May-17 13:44 
Hi,

I am using Web Api call, jQuery in my MVC application View to populate fields which is of Customers,
  1. I am planning to implement a partial View which has a table to display Purchase History of selected Customer, when a new item is selected in the View fields, then the partial View should display the values in the Table, but I don't know how to render partial view when using Web Api
  2. Another one is same this partial view contains one dropdown list, list box, add and delete buttons, when we select an item from dropdown list and say add then it will add in the listbox, when we select from listbox and say delete it will delete from the listbox. But by default when a Customer is selected it will display the selected items of this purchase in the Listbox.
Can anybody please suggest me little bit about Partial Views?

This is my Web Api Get, for first try I am calling the max Last Name Customer values to test:
        public object Get()
        {<br />
            dynamic model = null;

            using (AppDevSecEntities ctx = new AppDevSecEntities())
            {
                BSCCrystalReportsViewerEntities ctx2 = new BSCCrystalReportsViewerEntities();

                string maxCustId = ctx.Customers.OrderByDescending(x => x.LastName).First().CustId;
        DataTable Orders = Common.ConvertToDataTable<Order>(ctx.Orders.Where(x=> x.CustId==maxCustId));
        DataTable SelectedProducts = Common.ConvertToDataTable<Product>(ctx.Products.Where(x=> x.CustId==maxCustId));

                //return
                model= 
                    new
                    {
                        SingleCustomer = ctx.spGetShortSingleCustomer(maxCustId).FirstOrDefault(),
                        Orders = Common.ConvertToDataTable<Order>(ctx.Orders.Where(x=> x.CustId==maxCustId)), //This is DataTable type
            SelectedProducts = Common.ConvertToDataTable<Product>(ctx.Products.Where(x=> x.CustId==maxCustId)) //This is DataTable type
                    };
            }

            return model;
        }

Here is how I am calling the get, in this call only the Partial View should display me the table with selected Orders and another Partial View should display me the List box with selected items, those values are being returned by the Get call. Any help will be lot helpful - thanks in advance friends.
public object Get()
        {<br />
            dynamic model = null;

            using (AppDevSecEntities ctx = new AppDevSecEntities())
            {
                BSCCrystalReportsViewerEntities ctx2 = new BSCCrystalReportsViewerEntities();

                string maxCustId = ctx.Customers.OrderByDescending(x => x.LastName).First().CustId;
        DataTable Orders = Common.ConvertToDataTable<Order>(ctx.Orders.Where(x=> x.CustId==maxCustId));
        DataTable SelectedProducts = Common.ConvertToDataTable<Product>(ctx.Products.Where(x=> x.CustId==maxCustId));

                //return
                model= 
                    new
                    {
                        SingleCustomer = ctx.spGetShortSingleCustomer(maxCustId).FirstOrDefault(),
                        Orders = Common.ConvertToDataTable<Order>(ctx.Orders.Where(x=> x.CustId==maxCustId)), //This is DataTable type
            SelectedProducts = Common.ConvertToDataTable<Product>(ctx.Products.Where(x=> x.CustId==maxCustId)) //This is DataTable type
                    };
            }

            return model;
        }

        $.get("/api/EmployeeAPI/Get").then(function (data) {

            var list = $("#ddlProduct");
            var selectedValue = list.val();

            list.empty();

            $.each(data.Products, function (index, Product) {
                $("<option>").attr("value", Product.ProductID).text(Product.ProductName).appendTo(list);
            });

            if ((selectedValue == null) || (selectedValue == undefined)) {
                list.prepend("<option value='-1' selected='selected'>Select value</option>");
                list[0].selectedIndex = 0;
            }
            else {
                list.val(selectedValue);
            }           

            var date;

            if ((data.SingleCustomer.PurchaseDate != null) && (data.SingleCustomer.PurchaseDate != '') && (data.SingleCustomer.PurchaseDate != 'undefined')) {
                date = data.SingleCustomer.PurchaseDate;
                var d = new Date(date.split("/").reverse().join("-"));
                var dd = d.getDate();
                var mm = d.getMonth() + 1;

                if (dd < 10) { dd = '0' + dd }
                if (mm < 10) { mm = '0' + mm }

                var yy = d.getFullYear() + "";
                var Purchasedday = yy + "-" + mm + "-" + dd;

                $("#dtFieldPurchaseDate").val(Purchasedday);
            }

            if ((data.SingleCustomer.RePurchaseDate != null) && (data.SingleCustomer.RePurchaseDate != '') && (data.SingleCustomer.RePurchaseDate != 'undefined')) {
                date = data.SingleCustomer.RePurchaseDate;
                var d = new Date(date.split("/").reverse().join("-"));
                var dd = d.getDate();
                var mm = d.getMonth() + 1;

                if (dd < 10) { dd = '0' + dd }
                if (mm < 10) { mm = '0' + mm }

                var yy = d.getFullYear() + "";
                var Purchasedday = yy + "-" + mm + "-" + dd;

                $("#dtFieldRePurchaseDate").val(Purchasedday);
            }
        });

Thanks,

Abdul Aleem

"There is already enough hatred in the world lets spread love, compassion and affection."

-- modified 23-May-17 20:03pm.
AnswerRe: Need some help in implementing Partial View Pin
jkirkerx24-May-17 12:33
professionaljkirkerx24-May-17 12:33 
GeneralRe: Need some help in implementing Partial View Pin
indian14324-May-17 13:26
indian14324-May-17 13:26 
GeneralRe: Need some help in implementing Partial View Pin
jkirkerx25-May-17 10:08
professionaljkirkerx25-May-17 10:08 
Questioncell_double click even on grid view Pin
Mayank Kumar23-May-17 0:14
Mayank Kumar23-May-17 0:14 
AnswerRe: cell_double click even on grid view Pin
Maciej Los23-May-17 20:19
mveMaciej Los23-May-17 20:19 
QuestionReturn message to user if file already exists Pin
Hamiltonian1322-May-17 10:59
Hamiltonian1322-May-17 10:59 
AnswerRe: Return message to user if file already exists Pin
F-ES Sitecore22-May-17 22:59
professionalF-ES Sitecore22-May-17 22:59 
GeneralRe: Return message to user if file already exists Pin
Hamiltonian1324-May-17 8:14
Hamiltonian1324-May-17 8:14 
QuestionSingleton Class in Asp.net application Pin
Rafique Abdullah19-May-17 21:54
Rafique Abdullah19-May-17 21:54 
AnswerRe: Singleton Class in Asp.net application Pin
Nathan Minier20-May-17 12:43
professionalNathan Minier20-May-17 12:43 
GeneralRe: Singleton Class in Asp.net application Pin
Rafique Abdullah22-May-17 7:15
Rafique Abdullah22-May-17 7:15 
GeneralRe: Singleton Class in Asp.net application Pin
F-ES Sitecore22-May-17 22:50
professionalF-ES Sitecore22-May-17 22:50 
QuestionHow to populate dropdownlist in the partial view, base upon the selection of another dropdown value in the view, using angular js Pin
Member 1318632317-May-17 20:16
Member 1318632317-May-17 20:16 
QuestionError Pin
Member 1116162516-May-17 20:10
Member 1116162516-May-17 20:10 
AnswerRe: Error Pin
Kornfeld Eliyahu Peter16-May-17 21:27
professionalKornfeld Eliyahu Peter16-May-17 21:27 
AnswerRe: Error Pin
Richard MacCutchan16-May-17 21:36
mveRichard MacCutchan16-May-17 21:36 
AnswerRe: Error Pin
F-ES Sitecore16-May-17 22:11
professionalF-ES Sitecore16-May-17 22:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.