如何在ASP.NET MVC中将HTML文本框的值传递给actionmethod [英] How to pass value of HTML textbox to actionmethod in ASP.NET MVC

查看:61
本文介绍了如何在ASP.NET MVC中将HTML文本框的值传递给actionmethod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有控制器中的动作方法,我想将文本框的值传递给控制器​​,但问题是我无法传递值似乎是控制器中的空值。

我有登录按钮,在导航栏上弹出它只在索引视图上运行,但每当我通过其他视图并单击按钮弹出窗口显示,并在输入用户名和密码时,然后单击登录按钮它将空值传递给控制器​​



我尝试过:















< a href =@ url.action(登录,主页,新{用户名,密码})







**控制器**

公共行动结果login(string username,string password){

return view();

}

I have on action method in controller and i want to pass the value of textbox to controller but problem is that i cant pass the value is seem like null value in controller.
I have login button, has popup on nav bar it run on only index view but whenever i goes through other view and click on button popup shows and when putting username and pasword then click on login button it pass null values to controller

What I have tried:







<a href="@url.action("Login","Home",new{username,password})"



**controller**
public actionresult login(string username,string password){
return view();
}

推荐答案

您好,



试试这个:



Hello,

Try this:

<a target="_blank" href="@Url.Action("login","Home", new { username = "txtUserNameValue", password = "txtPassword"})"></a>



谢谢

Ajay


Thanks
Ajay


这篇关于如何在ASP.NET MVC中将HTML文本框的值传递给actionmethod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆