问题标签 [html.beginform]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
555 浏览

c# - 使用 HtmlHelper.BeginForm 扩展方法添加到 URL 路径

我有一个现有的 ASP.NET MVC 4 应用程序,它在视图中使用HtmlHelper.BeginForm方法。该站点现在将位于反向代理后面,该代理会将一些字符添加到 URL 的路径部分中。我希望为 HtmlHelper 创建一个扩展方法,允许我执行以下操作:

并且能够从以下位置修改输出:

改为:

0 投票
1 回答
2747 浏览

asp.net - 如何从 @using (Html.BeginForm(

在我的剃刀视图中,我有一个简单的表单,它将接受用户的日期:

如何在我的 CancelByDate 操作中获取这些数据?

我尝试了几种方法:

所以我想知道我错过了什么?

0 投票
1 回答
126 浏览

asp.net - Beginform 不发送视图模型,也没有到达我的 httppost 方法

我有一个奇怪的情况。我BeginForm在 ASP.NET MVC 中使用帮助程序。通常,如果您在视图上使用视图模型,那么它将发布到视图模型到我的控制器。

现在它将命中我的 HTTPGET 方法,该方法没有参数。我最好的猜测是视图模型没有被发送回服务器。

我在下面附上了我的视图、控制器和视图模型代码。

提交表单时,如何确保我的 HttpPost 方法被击中?我在做一些明显的错误吗?

我的看法

我的控制器:

我的视图模型:

0 投票
1 回答
2455 浏览

asp.net-mvc - 在 Html.BeginForm MVC 之外提交表单

我希望能够在 Html.BeginForm 之外提交一个表单,这就是我所拥有的并且正在表单内工作..

我环顾四周,找到了一个解决方案:给你的 Html.BeginForm 起一个这样的名字:

然后使用这个:

但是是否可以在 Url.Action 中使用相同的东西而不是 onclick,因为我需要控制器中的功能?

干杯

0 投票
2 回答
58 浏览

c# - 从单个 BeginForm 使用不同的操作

我有一个表格,其中显示了产品的详细信息。提交此表格后,它会进入“Dropshipment”操作,因为我的 beginformm 是

但是,在编辑过程中,我使用相同的 UI 来允许编辑,现在当我提交时,显然它会再次进入“Dropshipment”操作。但是我希望它提交给“编辑”操作。

我怎样才能做到这一点?

下面是我如何把我的部分 在此处输入图像描述

0 投票
0 回答
871 浏览

c# - Using BeginForm() To Upload File and passing Att' (ASP-MVC 4)

I have a ASP.NET MVC 4 Project, and I need to be able to upload a file or files to save them and make an instance of that file or files( so I will be able to keep information about them).

In order to implement this I have two classes inside of 'Models':

1. UploadFile: (this class will represent a single file)

2. Scan: (this class will represent a one upload of file or files)

also I have one controller 'HomeController.cs", and I have this action in there:

And the View is 'index.cshtml', and this is the begin.form:

My Main Goal: upload a file/files (save them at "~/Content/UploadFiles") and during this process to create an instance of UploadFile and Scan (Scan hold a collection of UploadFile), so i can represent them to the user and keep tracking and catalog them in my DB.

My problem is that "scan" is null in 'homecontroller.cs' how can i pass argument so i could create instances of the two classes and still upload the file ?

As you may notice i'm new at MVC design-structure, so if i'm missing a point or two of MVC because of my implement let me know. Thanks.

0 投票
1 回答
1407 浏览

asp.net-mvc - 未指定新图像时,Html.BeginForm POST 覆盖图像数据?

这是我在 StackOverflow 上的第一篇文章。我希望这很有用。

我有一个 Razor 视图,旨在允许编辑包含预定义值或空值的模型的可显示属性。视图不应更改模型属性的内容,除非用户通过在基于视图的 UI 中编辑它们来故意更改它们。视图行为正确,除了byte[]包含图像数据的类型属性:Model.ImageData

上述视图适用于模型中的所有属性,除了Model.ImageData. 在这种情况下,发布会导致任何先前设置Model.ImageData为空。Model.ImageData通过在发布之前验证是否Model.ImageData包含有效的字节数组(带有预期的图像),我已经确认在发布期间将其设置为 null。

上述视图的控制器代码为:

这是更新模型的存储库代码(尽管在调用此代码之前模型正在更改):

我究竟做错了什么?

0 投票
2 回答
789 浏览

c# - Html.BeginForm() 未正确呈现

在stackoverflow中搜索时,其他问题对我的情况并没有帮助。如何调试此类错误,例如 Html.BeginForm 未正确呈现到页面的错误。

我使用此代码

编辑:添加了模型

**** 编辑 ****

我得到了这个表格

我现在的表格。

http://i834.photobucket.com/albums/zz268/gtas/formmine_zpsf6470e02.png

我应该收到一份像我这样复制代码的表格

从教程中复制的外观

http://i834.photobucket.com/albums/zz268/gtas/formcopied_zpsdb2f129e.png

任何想法在哪里或如何寻找使我的生活变得艰难一段时间的邪恶根源?

0 投票
1 回答
145 浏览

javascript - 在运行时使用 Html.BeginForm

我想有条件地使用 Html.BeginForm。代码中有2个字段如下

和 JS 是

如果 secondlabel 为空白或为空,那么我想通过另一个操作提交表单,那么我该如何实现呢?

通过另一个动作,我的意思是:

0 投票
1 回答
909 浏览

asp.net-mvc - 在 Html.BeginForm 中使用 ViewBag 作为路由值将 ViewBag 值转换为小写

我试图通过 BeginForm 的路由集合传递一个加密的字符串,方法是在 ViewBag 中传递它,例如:

ViewBag.Id是一个动态加密的字符串,例如:g9IPGGXm4jw=

不幸的是,当它通过表单提交到达我的控制器时;它以小写形式出现,例如:g9ipggxm4jw= 这会导致解密过程出现异常。

有人知道它在哪里变成小写吗?