A scenario in ASP.MVC Application [closed] - c#

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
We are creating an ASP.MVC Application. We are following a MVC pattern.
In a page, we need to show a chart. Now, my senior suggests me a way which doesn’t follow MVC pattern.
My Way(follow MVC pattern) – On the button click, handle an input request by controller. Controller handles the model and view. View renders the chart on the browser which is simple MVC pattern.
Senior suggestion – Don’t waste your time on Model, controller.(as per him, this process will take extra time.) Direct call to a JS function on the button click. JS function using Ajax call, get the data from the DB and provide the data to chart. Chart will render on the browser.
In above scenario, which way should I follow?
Please suggest.

Since the js function is calling a method of one of your controllers, the MVC pattern is not violated. Just a call to the controller without loading the whole page. Trust your Senior ;-)

Related

Using angular 4 for making just ajax call [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I want to use Angular 4 for doing small operation like just making ajax call. Note: I know, I can use plain jquery to do this... blah... blah...
Question:
What Angular 4 Nuget Packages I need to Install for doing small operations like just making ajax call. Any example will help.
Technologies I am working with: Asp.net MVC, .Net Core, C-Sharp
This would be an inappropriate use of Angular. Angular is a client-side technology whose primary purpose is to provide a single-page application (or SPA) user interface for a Web application.
The idea is that the entire application runs on the client and does not require going back to the server to navigate between the pages of the application. The only time an Angular application needs to hit the server is to get data or to lazy load more of the application.
It makes no sense to use Angular within an MVC application to retrieve data.

ASP.net Core: Is it normal to call method of different controller from view? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I have 2 controllers: FirstController and SecondController.
First controller contains GET method GetFirstData for send some data.
Second controller contains similar method GetSecondData for send different data.
I also have 2 views Index.cshtml for each controller.
I know that call GetFirstData method from Index.cshtml view is normal. But is it good to call GetSecondData method from Index.cshtml of FirstController? E.g. using AJAX with #Url.Action("GetSecondData", "Second")
Yes, you can do like this. If you are using Ajax to call that method, there wouldn't be any problem.
Yes you can do that for sure, you can simply use the controller methods as web calls by AJAX but I would recommend that:
1-If GetSecondData is being used by many views across various controllers, I would recommend you separate it in a separate controller.
Why? Because it seems like this method is more general than being bound to a specific controller with much of views and Actions
2-I would also recommend you separate the AJAX function in a separate JS file and include it in the views which are interested in the function.

How to: CRUD Using AngularJS and MVC Web API [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I would like to use AngularJS and MVC Web API to create a form and its CRUD operations (see image below)
The form is constituted of three tables: Page, Preamble, Sections. It also has 3 drop down lists that will need to be populated from the database.
This is my first attempt to create a project like this one, and I am finding lots of examples and most of them use only one table.
Do anybody has an tutorial/ example in which more than one table is used?
There are lots of Angular tutorials at the end of a Google search, but can I suggest that you not think of your page controls/layout as being sourced from tables in a database but more as results returned from an API call (actually you shouldn't even be thinking about it like that, but it will start you on the right road) - ultimately these values may well be formed as a result of some database query but from the UI perspective that's implementation detail that it shouldn't be privy to.
Rather than:
Title, SEO Title, Percent Page = "Page Table"
Consider:
Title, SEO Title, Percent Page = api/pages/{page}
Then the implementation behind api/pages/{page} is hidden from the UI and so not tightly coupled to the database schema.

Change windows form application into MVC [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have an application which is built in windows form C# where I have a View, a Model and s ManagerHelper folder with classes in it. I wanted to convert this application into MVC application.
I know it's not convertable and needs to be implemented from scratch. The reason I wish to create to an MVC project is because I'm new to MVC and wish to learn it.
I'm familiar with HTML syntax however this seems to be really hard to get a grip of.
So my question is: What would a good approach if I which to change my windows form application into an MVC application.
Any link to articles or any books recommendation for Learning MVC would be helpful as well.
There was an article about this in MSDN magazine last year. It should help guide you. You can read it HERE

AngularJS form validation with MVC 4 [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I'm building a single page web application. This has many different forms on it that will require validation. I'm not using any of the Razor form validation, or views. Instead everything is held in Angular templates.
I get my data from the server using Web Api calls, including lists of form elements as many of the forms are dynamic.
I would prefer that my models hold all of the validation. I know I could duplicate this validation onto my angular templates for forms that aren't dynamic but this means that the validation has to be maintained in two places - I would rather keep it in one place, on my model, so that client and server validation are inline with each other.
What would be the best way to extract the validation on my model and use it on the front end?

Categories

Resources