- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
这是我在 MVC2 中的第一个应用程序。以下是我的 View 、 Controller 和另一个显示输出的 View 。
StartPage.aspx
<form action="DisplayCustomer" method="post">
Enter customer id :- <input type="text" name="Id" /> <br />
Enter customer code :- <input type="text" name="CustomerCode" /><br />
Enter customer Amount :-<input type="text" name="Amount" /><br />
<input type="submit" value="Submit customer data" />
</form>
CustomerController.cs
public class CustomerController : Controller
{
[HttpPost]
public ViewResult DisplayCustomer()
{
Customer objCustomer = new Customer();
objCustomer.Id = Convert.ToInt16(Request.Form["Id"].ToString());
objCustomer.CustomerCode = Request.Form["Id"].ToString();
objCustomer.Amount = Convert.ToDouble(Request.Form["Amount"].ToString()); ;
return View("DisplayCustomer", objCustomer);
}
}
DisplayCustomer.aspx
<div>
The customer Name is <%= Model.Name %> <br />
The customer Code is <%= Model.Code %> <br />
<% if (Model.Amount > 100) {%>
This is a privileged customer
<% } else{ %>
This is a normal customer
<%} %>
</div>
上述方法论对我来说效果很好。但我想将其更改为以下内容,就像我正在关注的教程中那样。我还在此处包含了错误消息。
StartPage.aspx
<% using (Html.BeginForm("DisplayCustomer","Customer",FormMethod.Post))
{ %>
Enter customer id :- <%= Html.TextBox("Id",Model)%> <br />
Enter customer code :- <%= Html.TextBox("CustomerCode",Model) %><br />
Enter customer Amount :- <%= Html.TextBox("Amount",Model) %><br />
<input type="submit" value="Submit customer data" />
<%} %>
错误信息
'System.Web.Mvc.HtmlHelper' has no applicable method named 'TextBox' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.
CustomerController.cs
[HttpPost]
public ActionResult DisplayCustomer(Customer obj)
{
return View(obj);
}
我已经提供了指向我正在关注的教程的链接。在那篇教程中,LAB5 是我一直面临的问题,它位于页面底部。
http://www.codeproject.com/Articles/207797/Learn-MVC-Model-View-Controller-step-by-step-in-7?fid=1631845&df=90&mpp=25&sort=Position&spc=Relaxed&tid=4684984
我在这里发帖之前试了很多,都没用。请帮助。请记住,我是 MVC 的新手,这是我的第一个应用程序。
最佳答案
目前 MVC 5 已经发布,你有更完整的 MVC3 和具有许多移动功能的 MVC4!为什么不迁移到最新版本?
或者请安装 MVC 3 www.asp.net/mvc然后更正你的看法如下
<% using (Html.BeginForm("DisplayCustomer","Customer",FormMethod.Post))
{ %>
Enter customer id :- <%= Html.TextBoxFor(model=>model.Id)%> <br />
Enter customer code :- <%= Html.TextBoxFor(model=>model.CustomerCode) %><br />
Enter customer Amount :- <%= Html.TextBoxFor(model=>model.Amount) %><br />
<input type="submit" value="Submit customer data" />
<%} %>
关于c# - 'System.Web.Mvc.HtmlHelper' 没有名为 'TextBox' 的适用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22983961/
这个问题在这里已经有了答案: Is Git’s "master" branch name more than just a name? (3 个回答) What will break if I don
我使用了Plone实例文件夹的“bin /”目录中的“paster”命令来创建一个名为“MyApp”的plone应用程序(来自模板),该命令是: (from instance's root folde
我正在尝试覆盖 FOSUserBundle 的用户映射的两个属性。 use FOS\UserBundle\Model\User as BaseUser; ... use Symfony\Bridge\
工作通过 these posts让我认为我了解自我类型,至少在某种程度上。 所以我创建了一个按预期失败的例子: scala> trait A { val v = "a" } defined trait
我在 IntelliJ 中有一个 JavaFX Maven 项目,它使用 Hibernate。当应用程序启动时,我收到以下错误消息: No persistence provider for entit
我正在尝试构建一个数据透视表,并使用开源代码并摸索着这个函数。record[] 如何传递给这个函数?似乎没有经过或任何声明。怎么能直接来呢? 完整代码可以在这里找到https://github.com
我的应用程序有 abc.com 链接,这是一个主页和 abc.com/user123(有一个动态部分),这是一个用户登录的特定配置文件页面。 早些时候,我通过这样做实现了这一点: this.route
当我在使用 mac book pro 的 Android Studio 上设置 Flutter Sdk 路径时,我遇到错误 Flutter SDK 路径未给出(并且打开一个弹出窗口并显示消息“名为‘F
我刚刚设置了 Postgres 供我网络上的不同用户使用。每个用户都有自己的用户名/密码/数据库,但是当我连接到 Pg 时,我还可以看到一个“postgres”数据库(甚至可以创建表等)。我试图从公众
我正在尝试从 MySQL 数据库中获取一些数据。所以我要做的是: select * from my_table where 'to' ='0000-00-00 00:00:00'; 这给了我空集,但我
我有一个名为“索引”的表。我意识到这是 MySQL 中的关键字,想知道如何在查询中引用该表? 我的错误: #1064 - You have an error in your SQL syntax; c
我在机器 myuniversity.edu 上设置了一个远程 mysql 数据库服务器,服务器名为“localhost”。我在上面有一个名为“MyDatabase”的数据库。 I want to co
我正在尝试使用 Android NDK 构建应用程序。我已按照所有步骤操作,一切正常,正在制作 .so 文件。但是在 Eclipse 中,当我尝试清理项目时出现以下错误: The file does
我正在重写 UIImage 类方法 init(named:)。我的目标是能够检索图像的文件名。 代码看起来像这样: class UIImageWithFileName: UIImage { l
@ThreadSafe public class A { } 这个注解实际上使类线程安全还是只是为了提高可读性? 最佳答案 参见 @ThreadSafe Annotation : Place this
当我将第二个表(dtResult)添加到数据集时出现错误 名为“Table”的数据表已属于此数据集。 DataTable dtSession = new DataTable(); DataTable
这个问题可能看起来重复,但略有不同。在 SO 的所有其他问题中,我注意到他们注册了多条路线。但就我而言,我只有一条路线。 我正在创建 asp.net webapi(框架 4.5)并且在 Registe
我最近将 Microsoft.AspNet.WebApi.WebHost 添加到 MVC WebAPI 项目中,这将允许我使用 [Route("api/some-action")] 归因于我的行动。我
我有一个名为“异常”的命名空间的问题 让我们考虑以下示例标题: #include namespace exception { struct MyException : public std::e
我昨天安装了 Nuget 1.2,今天,当我尝试安装 Entity Framework 包时,我在包管理器控制台中遇到了以下问题: PM> install-package entityframewor
我是一名优秀的程序员,十分优秀!