I'm working on a university project and trying to learn MVC3 at the same time. I have a shopping basket style page with a table that shows the items. The model contains a list of products purchased.
I can display the products in a table via looping through the Model and displaying, however I need to implement a way to update the quantities. I currently have the quantities displayed in a HTML.TextBox which can be amended, but when I change the value it's not represented as such in the model.
Could somebody please advise how I could do this.
Thanks.
To update the model, you have post the edited values back to the server. To populate the model values in a text box, you can use the Html.EditorFor extension method and Pass in the lambda expression pointing to the quantity property. You can put the shopping cart controls within an HTML form control with an action of "post" and target of the controller route which will update the model. These are very basic operations in Asp.Net MVC, and you should be able to see how it is done in www.asp.net/MVC
Please do some research before posting your questions in the forum.
Related
I'm using a kendo dropdownlistFor and populate it by items that a user is able to add. and I'm using a modal dialog which sends an ajax POST to the controller. Now my question comes forward.
Is there any straight way (not using HiddenFor, or tricky Js or Jq stuffs. instead using MVC or Kendo functions) to pass the whole items of this DropdownList to the controller?
What I have now, is a kendo dropdownlistfor and a property of List. the Post returns, of course, the selected item id.
Thanks in advance for any suggestion.
I am currently trying to do a similar thing with my project. As far as I have been able to discover there is no way to do this without having a JS function, ticket ongoing. However your case may be possible if I understand it correctly. The user passes in items to your dropdown correct? So if you were to save those items into a List and then pass that list into the controller it should work correctly. If you could give some of your code or a picture of your UI I may be able to give you a bit more direction. Hope this helps!
I've been working on a photography page for a while now. Now I've tried to create a page on which user will upload photos to database.
I wanted to give the user an option of selecting photo categories on the create/upload page using checkboxes. I wanted to use a viewmodel with list of categoryview models which would represent the checkboxes.
Now the tricky part that i need some help with is how do I allow user to dynamically add new categories (if he needs to) on the same page. So how would i add new values into the list of categories on view.
Only thing that comes to my mind is to create an ajax post that would call a method that would create the new category in the database. Then i could append a new checkbox representing that category, But then i do not know how i would send that category in the list of categories in viewmodel without refreshing current page. Is this even possible?
If any1 has any ideas how to start on this I would be grateful.
I have a single oracle table with 5 columns and I need to create 5 cascading dropdown lists on the MVC view page, using combination of Razor and jquery. I got the first dropdown ok which comes from the Model passed on to the view. Having trouble figuring out the 2nd dropdown and after.
Any sample code or examples would be appropriated
Thanks
Mike
This is resolved. I ended up using jquery+ajax to make cascaded calls to the controller with each call passing the previous dropdown boxes values and returning a selectList of items from the DB.
Thanks
I am very new to MVC and I am not too conversant with the best practices here. I am facing a design issue which may be common or uncommon to newbies like me. My problem is the following:
I have a page with two parts in it.
Grid Control (with Employee basic info in it)
Employee Details (When someone clicks on Grid row, it loads all the details about the employee)
I am using KendoGrid and it is getting all its data from an ActionMethod from my controller.
Now, when I click on the row, I have the following options:
I call some ActionMethod in Controller and return all the Details
Should I use partial View with a separate model so that ActionMethod in response calls RenderPartialView()?
Should I NOT create a partial View, have Actionmethod return JSON and parse it in the Model?
3.1 If I go for this option then would the JSON be part of model?
3.2 If it is not going to be part of model, how can I use JSON to render the View?
Or probably I am missing something basic here?
Yes you can use action method returning JsonResult. what needs to be done is keep the uielements you need to show on the click of grid row in the page itself. initiate a ajax call to the action method and on success update the values of the UI elements from the values received in JSON and make the entire DIV as visible which holds the total information.
Instead of passing entire HTML over the network I think you can opt for json.
An example you can find at following location
example
am really new to MVC, i was web form developer but i happened to get involved in a project developed using MVC.
My view looks like this, 5 textboxes to enter values (stored as a List), when added will be displayed in a grid on the same view, gird has a edit and delete button. when user clicks on edit button the list of values will appear in each textboxes for the user to edit the values.
My Model has List Values.
Please shed some insight on how to achieve this scenario.
Thank you,