Reputation: 2669
I've created a simple .NET MVC project, following the walkthrougth on MSDN.com.
I'm confused about how I'd go about adding a button to the page, so that I can map an action to it.
I've tried searching the web for this, but haven't found what I'm looking for.
Does anyone know of any resources that could help me?
EDIT
The JS for the search bar is below.
<script type="text/javascript">
$(function () {
$('#search').MyApp('init');
$('#search').bind('selectItem', function (event, target) {
alert($(target).attr('data'));
});
// $.getJSON("http://localhost", {},
// function (x) {
// // var x = [1, 2, 3];
// alert("test");
// });
// alert('here')
});
</script>
Wha do I need to do to add a search button you can click?
Upvotes: 0
Views: 5535
Reputation: 669
you can it like this..
in your razor view
@using(Html.Beginform("action", "controller")){
//insert some form
<input type="submit" value="OK" />}
and in your controller you must define a action with that actionname that makes the logic
Upvotes: 4
Reputation: 7200
You can find a lot of helpful tutorials and videos on the ASP.NET web site.
Upvotes: 1
Reputation: 2249
You cannot map an action directly to a button. You can however determine in the controller which button made a submit call.
2 other options:
Upvotes: 0