I want to create a post so I'm using the create method of post controller. but this page has category and subcategory fields and I want to get the subcategories using AJAX.
The question is which controller is more appropriate to get the subcategories?
AJAX controller
Post controller
Category controller
If it's only one method then you should implement it in CategoryController because maybe other entities of your project will have relations with categories. It doesn't make sense to query route to PostController to get categories for select on, let's say, user category permissions editing page.
But if you need a bunch more methods it would be better to delegate a separate CategoryApiController for different AJAX methods and group it's routes separately too.
Related
I have one resource (User table) for which I need to perform some action.
However when that action selected I want to pass too many additional fields and selection is dynamic.
For example, if I select any user and click on action then in action I should select a category from DB and based on that category I need to get subcategory and based on that subcategory I want to get some seller on action page in Nova...
Is there any way i can do this.
I think Action Fields might help you with that. You can add additional nova fields to your collection of models before handling them in the action.
Hope that this can help: nova action fields
you can use this great NovaPackage
https://github.com/epartment/nova-dependency-container
Currently we have a few products defined in Orchard.
We managed do display these products by using a query in combination with projection.
I executed the same steps as described in this tutorial, Defining and rendering the ProductCatalog Content Type
There is also a menu to navigate inside products catalog. When selecting category, the full page is refreshed. How can we implement a ajax request each time user select a product category in menu?
Here i will show you an example of the screen:
I guess your best bet is to do something along those lines:
Create a module with a custom ApiController
Write an alternate for your category navigation in which you send an ajax request to your controller
Use IContentManager in your controller to query for your products and return them as a json result
Update your page from your result
I am following this tutorial; http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-8
In my project, I want to pass the rental price which is radio button value instead of 'Price'.
How do I pass the radiobutton value for cart with using ajax?
Here is my source details..could you tell me how to pass the radiobutton value with ajax?
I am stock from last 2 weeks really.. I need to your help.
Thanks.
MVC3 passing the radioButton value for shopping cart
I'm not sure you are going to be able to create a decent MVC app by hacking the MVC Music Store without understanding it.
If you go back and actually do / redo the tutorial then I'm sure you will be able to answer your own question.
The link you provided shows
1) How to form post to AddToCart
2) How to post via Ajax in RemoveFromCart
So all you need to do is change AddToCart Controller and View to use the Ajax Post (like RemoveFromCart) and include the selected radio buttons Price value in the post to the controller.
It's all there in the tutorial.
Good Luck!
I have a pretty standard scenario where I have a model which in this case is a product.
The product model has a load of properties such as price, desc etc which I want to display on a view.
I have this working fine.
The product has a list of accessories objects which get displayed on the view and gives the user the ability to enter a qty for that accessory.
When the user clicks add to basket I only actually need the list of accessories and the id of the parent product.
Should I be creating a view model that contains all the product info I need or do I just pass my view the product and then on submit just get a view model for the few fields that I need in the signature of the function?
I'm new to mvc in case you hadn't guessed!! and I am using MVC 3.
Using a separate view model is better practice as it means you can add extra information outside of the Product which may be relevant such as Basket and User info. If you have many fields on the product then you can use Automapper to take the relevant fields and map them to the view model. Also you can flatten the model if necessary and make serverside queries which fecth all of the model's related items such as Category info etc.
Take a look at Automapper here:
http://lostechies.com/jimmybogard/2009/01/23/automapper-the-object-object-mapper/
once you start using it you won't look back.
The academic way would be to crete a separate ViewModel class with just the data you need in the view.
But when you are comfortable with ignoring the extra fields in your class i think its absolutely ok to use your Product model class in the view.
What I am trying to do using asp.net MVC3:
-User selects a Category from a list of Categories.
-The SubCategories page then displays a list of images found to represent that Parent Category as well as the list of SubCategories.
I run into the need for multiple models because the "Category Images" are associated with Category and not the "SubCategory model". Yes I realize this seems like it has been asked many times before but the syntax is still foreign to a noob like me. What goes where?
I got the Category -> Html.Actionlink to the controller to return a list of SubCategories part... but even if I did some left join to get category and list of images as well, how would I get those into the same view as the list of subcategories?
Update
Found this posting:
http://francorobles.wordpress.com/2011/05/03/returning-multiple-models-in-1-view-in-asp-net-mvc3/
Question: Is that a valid approach? My intellisense suggests no.
In cases like this you need "view models", i.e. view-specific models that have all the data your view needs.