How to call Action when click on submit button.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 năm cách đây
Hey there

I am new to MVC and nopCommerce.I am developing application for my client

I need help to learn nopCommerce hop you help me

here is my questions

how can i know call the Action when click on submit button.i.e. I create on form which has one html submit button called save.how can I call Save action from controller when I click on that button?

thanks
11 năm cách đây
Not sure I fully understand your question (I have an idea but I’m not sure).

If I understand correctly, your question is not really related to nopCommerce but more towards how asp.net MVC works. How things are handled when a user clicks a submit button.

Considering nopCommerce has a full set of features and considering it has a programming architecture in place, you must understand that you’ll have to follow its idea and architecture. Nop does have its Pros and Cons and understanding them takes some prior knowledge of asp.net MVC and design patterns.

If you wish, you could try and learn asp.net MVC within nopCommerce but for anyone who’s never been exposed to asp.net MVC, I’d rather they start with something else. Of course, that’s easy for me say considering I have no idea what is your current project and how urgent it is…but if you CAN, then I’d try a different open source project to learn such as Nerd Dinner…

In a nutshell, when a request is made by a user (targeting an asp.net MVC web site), things differ from an ordinary asp.net Webform application. The Controller’s responsibility is to intercept that user’s request and look for the appropriate ActionResult method. Once it finds it, it invokes that method which in turn, returns a View (not always but usually).

It is that View that is then sent to the user’s browser. Generally, the View in asp.net MVC is a file which has the .cshtml extension because of the ViewEngine (the default ViewEngine in MVC is called Razor). Yes, you could use a different ViewEngin inside your Views but that’s beside the scope of your question.

Inside a .cshtml file, you’ll recognize some HTML code and in that code, you’re allowed to create a
<form>…</form>
in which you’ll have a submit button.

Once the user clicks that submit button, it triggers a request and, like I’ve mentioned before, that request is then intercepted by a Controller which looks for the method (ActionResult) to execute.

I’m not going to go in details about how to create and submit a form in asp.net MVC because it would take forever to talk about the many scenarios…but I strongly invite you to find an asp.net MVC tutorial/videos that explains the basics of how things work.

Once you’ve got that covered, you’ll thank yourself and you’ll be more ready to tackle nopCommerce.
If that does not answer your question, then perhaps you’ll need to be more specific so people here can better answer you.

Hope this helps!
Sincerely
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.