我的布局中有这个按钮,通过单击事件更改值:
<input type="button" id="switchbutton" value="Weekend" style="color:blue" onclick="toggle(this);">
<script type="text/javascript"></script>
<script>
function toggle(button) {
switch (button.value) {
case "Weekend":
button.value = "Week";
break;
case "Week":
button.value = "Weekend";
break;
}
return value;
}
</script>
我需要将按钮的值发送到我的控制器,以便在以下条件下使用它:
if (Button.value =="Weekend")
{
Do something
}
else
{
Do antoher thing
}
你能帮我把布局上的按钮发送给我的控制器吗?
您应该能够在表单帖子上获得与视图类似的值。
public ActionResult Edit([Bind(Include = "switchbutton")] YourModel yourModel){
string myValue = yourModel.switchbutton;}