Possible Duplicate:
Mvc Html.ActionButton
使用 ASP.NET MVC 3
I know how to create a link to a to a actocle a move 方法, 我知道如何非常容易地创建链接, 但我想知道的是, 您( 点击) 如何按下按钮, 如何调用特定的行动方法?
Possible Duplicate:
Mvc Html.ActionButton
使用 ASP.NET MVC 3
I know how to create a link to a to a actocle a move 方法, 我知道如何非常容易地创建链接, 但我想知道的是, 您( 点击) 如何按下按钮, 如何调用特定的行动方法?
萨钦
如果你再使用jquery(你没有提到,但我会用 mvc 表示它相当标准),你就会做以下工作:
$( #buttonId ).click(function(){
document.location = @Url.Action("MyAction","MyController") ;
});
当然,你可能想要使用ajax, 但这是一个基本的例子。
您可以使用 html
@using (Html.BeginForm("SomeAction", "SomeController", FormMethod.Get))
{
<input type="submit" value="Click me" />
}
How do you do it? The same way you would if not using MVC.
<INPUT TYPE="BUTTON" VALUE="Home Page" ONCLICK="window.location.href= /Controller/Action ">
以及达林对使用“获取表格”方法的回答, 您也可以调用“ 获取表格” 函数, 然后又会调用“ 获取表格” 函数。
您可以单击单击并运行您自己的代码时拦截按钮点击事件。 该代码可以使用 Ajax 或简单地浏览到操作方法, 自动调用动作动作 。
s 在这里取样用于拦截按键点击事件 的射线标本 。
$(document).ready(function () {
myButton.onclick = function (event) {
// in here you can call an ajax method or just navigate to an action
return false;
}
// or using jQuery
$( #myButton ).click(function (e) {
// do whatever here
e.preventDefault;
});
});
或者您可以拦截一个有 href 属性的按钮
$(function () {
$("#myButton").click(function () {
var href = $(this).attr("href");
var route = href + "?paramName=" + $( #SomeValue ).val();
$(this).attr("href", route);
});
});
此添加参数信息, 您可能存储在页面上的另一个输入中, 并将其附加到 Url 上, 然后导航到动作
I have a set of buttons that I want to add into an array so that they are ordered. The buttons I have are: Monday0700Button Monday0730Button Monday0800Button Monday0830Button and so on. How do I ...
I have disabled and css styled buttons. In Firefox, disabled buttons do not move at all when pressed (which is what is expected), in IE, the text in the buttons still moves a few pixels. Why does ...
In System.Windows.Forms.Button there is a property DialogResult, where is this property in the System.Windows.Controls.Button (WPF)?
I m trying to create a template for a button in Oracle APEX but I don t seem to have access to the appropriate substitution strings to make it work. For non-templated buttons APEX seems to insert a ...
I have created nearly 40 to 60 button controls dynamically on canvas control using WPF. Now I want to remove the selected button control from the canvas. How do I do this.
We have buttons of many sizes and colors that use background images. There is a label on the background image itself, but we need to keep the button s text in the HTML for usability/accessibility. How ...
In my (school) website we use Iframes to display class blogs (on blogger). This works well EXCEPT if the user then clicks on (say) a photo inside the iframe. Blogger (in this case) then displays the ...
I am so sorry if this question seems too easy but I can t seem to find it anywhere. I am creating a ruby in steel project. I have created a html.erb and rb file in a vs project (ruby on rails). My ...