English 中文(简体)
ASP.Net mvc Url. 动作参数始终无效
原标题:ASP.Net mvc Url.Action parameters are always null

对MVC来说是新来的 所以请忍耐我

我试图做的是,在第1页,用户将数值输入到两个文本字段中,在单击提交按钮时,它将调用 wcf 服务,如果 wcf 调用返回确认值,那么它应该重新定位到不同的页面,并显示从 wcf 调用返回的数值。

我创造出像这样的景象

      <input type="text" name="txtUniqueCode" value="@Model.UniqueCode" placeholder="unique identifier" />
            <label for="name">
                Vehicle Registration
            </label>
            <input type="text" name="txtRegistration" value="@Model.Registration" placeholder="Registration" />

            <a href="@Url.Action("ShowRepairDetails", "RepairDetails", new { uniqueCode = Model.UniqueCode, registration = Model.Registration })">Check Status</a>

用户在文本框 s 输入值后, 一旦点击“ 检查状态 ”, 就会尝试使用 Url. action 将值传递给控制器。 但是, 当我调试并检查控制器的参数值时, 他们就会以空号返回我。 不清楚为什么吗?

我尝试用以下URL中的静态值替换参数值。 Action-

  @Url.Action("ShowRepairDetails", "RepairDetails", new { uniqueCode = 1234, registration = "Test" })

工作正常, 我正正确接收控制器侧的参数值。 因此从我所理解的“ 模式” 对象, 即使用户将某些值输入文本框, 也不会更新。 我在这里缺了什么东西。 请帮助 。

Thanks in advance
Sai

最佳回答

您似乎误解了这里的工作流程。 您的代码中的链接由服务器计算, 将页面发送到客户端。 它无法使用用户稍后进入文本框的值。 要做到这一点, 您需要一个带有提交动作的表格, 或 AJAX 调用来提取 HTML 元素的值, 并将这些值发回服务器 。

问题回答

暂无回答




相关问题
WebForms and ASP.NET MVC co-existence

I am trying to make a WebForms project and ASP.NET MVC per this question. One of the things I ve done to make that happen is that I added a namespaces node to the WebForms web.config: <pages ...

Post back complex object from client side

I m using ASP.NET MVC and Entity Framework. I m going to pass a complex entity to the client side and allow the user to modify it, and post it back to the controller. But I don t know how to do that ...

Create an incremental placeholder in NHaml

What I want to reach is a way to add a script and style placeholder in my master. They will include my initial site.css and jquery.js files. Each haml page or partial can then add their own required ...

asp.net mvc automapper parsing

let s say we have something like this public class Person { public string Name {get; set;} public Country Country {get; set;} } public class PersonViewModel { public Person Person {get; ...

structureMap mocks stub help

I have an BLL that does validation on user input then inserts a parent(PorEO) and then inserts children(PorBoxEO). So there are two calls to the same InsertJCDC. One like this=>InsertJCDC(fakePor)...

ASP.NET MVC: How should it work with subversion?

So, I have an asp.net mvc app that is being worked on by multiple developers in differing capacities. This is our first time working on a mvc app and my first time working with .NET. Our app does not ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

热门标签