I am new to MVC. I have defined a button in one of my views (bootstrap):
<button type="button" class="btn btn-success btn-lg">
<span class="glyphicon glyphicon-star"></span> Star
</button>
Now, I want to execute some server side code when this button is clicked however I am not sure how to do it in an MVC project
. Where should place the server side code and how should I call it ? I am using Razor
.
your best bet is to look at jquery/ajax in the 1st instance as there are many. many examples on SO that allude to this pattern. Below is a quick sketch to get you going.
if your target url was mvc, then you'd replace the url parameter above with something like:
MVC stands for
model-view-controller
. We useController Classes
to handle incoming browser requests. Here you can call a method in your controller using java-script.It is better if you can follow the MVCMovie tutorial to get a clear understanding.
Thanks!