如何根据MVC中的文本框值检索值 [英] How to retrieve values based on textbox value in MVC
本文介绍了如何根据MVC中的文本框值检索值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友们,
我正在学习mvc。如何根据文本框值从数据库中检索值。
例如。我创建了登录页面,我给了用户名并单击登录按钮,然后在主页上显示用户名的名字和姓氏。
我已经尝试了很多时间,但它没有用。
我是什么尝试过:
我试过这个链接,但我无法理解其中一行:http://stackoverflow.com/questions / 10718263 / mvc3-text-box-text-change-event
Dear Friends,
I am learning mvc. how to retrieve value from database based on text box value.
For Eg. I created login page i give username and click login button then the username's First Name and Last Name display on home page.
I have tried lot of time but its didn't work.
What I have tried:
I have tried from this link, but i can't understand one lines in that: http://stackoverflow.com/questions/10718263/mvc3-text-box-text-change-event
推荐答案
我写了一系列针对初学者开始使用MVC的文章。这是链接:
[ ASP.NET MVC 5:构建您的第一个Web应用程序 - 第1部分
这篇文章是一个MVC 5应用程序,但MVC 3的概念应该是相同的。
如果你愿意,你也可以下载我的电子书,从头开始构建MVC应用程序的完整参考: http://www.c-sharpcorner.com/ebooks/asp-net-mvc-5-a-beginner-s-guide [ ASP.NET MVC 5:初学者指南]
I've written a series of article that target beginners to get started with MVC. Here's the link:
[ASP.NET MVC 5: Building Your First Web Application - Part 1]
The article was an MVC 5 app, but the concept should be the same for MVC 3.
If you'd like, you can also download my eBook for a full reference on building an MVC app from scratch: http://www.c-sharpcorner.com/ebooks/asp-net-mvc-5-a-beginner-s-guide[ASP.NET MVC 5: Beginner's Guide]
@{
ViewBag.Title = "Access TextBox and TextboxFor Value From View To Controller In Asp.net MVC";
}
@using (Html.BeginForm("Index", "Home"))
{
<b>Acess Textbox </b>
@Html.TextBox("Name","")
<br />
<input type="submit" value="Submit TextBox" />
}
[HttpPost]
public ActionResult Index(int id = 0)
{
string name = Request.Form["Name"].ToString();
return View();
}
这篇关于如何根据MVC中的文本框值检索值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文