问题标签 [html.hiddenfor]

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 回答
619 浏览

c# - 列表 in HttpPost is Null

I have an admin page in my MVC5 web application where a user is selected and upon clicking the proceed button a list of all roles with checkboxes appear (via Ajax). If a user is in any of these roles, the c

I have an admin page in my MVC5 web application where a user is selected and upon clicking the proceed button a list of all roles with checkboxes appear (via Ajax). If a user is in any of these roles, the checkbox will be checked automatically.

I want to pass a List in my HttpPost method once the user checks/unchecks the boxes for each role. However, the parameter to my action method is null but there are values in Request.Form.

I don't understand why that is. Also do I really need to use @Html.HiddenFor() for each parameter in my viewmodel in order for things to work correctly?

RoleCheckBoxViewModel

RolesController Action

The AllRoles Partial View (A result of a previous AJAX call)


  1. find -type f | git check-ignore --stdin gives all files ignored in whole repo (and if you have some in .git that fit, it will report them too).
  2. git ls-files --exclude-standard --ignored --others - gives ignored file per current directory (not whole repository).

Both solutions honor not just top-level .gitignore file, but also global one, .git/info/exclude and local (in lower-level dirs) .gitignores

0 投票
1 回答
41 浏览

c# - 渲染列表以表格形式发布给控制者

我正在使用 ViewComponent 渲染递归树结构,Html.HiddenFor并且Html.CheckBoxFor在表单中使用 and 时遇到了困难。

这是视图模型:

ViewComponent 是从主视图页面调用的,如下所示:

...这是 ViewComponent 的调用方法:

这是Default.cshtmlViewComponent 的:

它输出这个 HTML(这是它的一部分):

我在这里面临(至少)两个挑战:

  1. 该语句item.Products.Any(c => c.Id == productId);应评估是否在导航属性中找到true了局部变量的值,这意味着该特定产品已链接到该特定类别(通过),但现在它正在检查父类别中的所有同级类别。productIdProductsitem.Products

  2. 我认为 HTML 输出不正确,至少对于name-property: <input checked="checked" id="z0__Checked" name="[0].Checked" type="checkbox" value="true" />。可以命名[0].Checked吗?

我还没有编写控制器的POST-edit 方法,所以我没有将它包括在这个问题中。在其中,我必须做一些从一种模型到另一种模型的转换,以及其他一些事情。如果我可以让表单正确呈现,我可以将它绑定到控制器。

0 投票
0 回答
82 浏览

c# - 如何触发 @Html.TextBoxFor() 中的隐藏

我想隐藏输入

当 post 方法被实际触发时,我希望它之后隐藏输入。

这是表单编号输入和按钮输入。

我看过这个如何使@Html.EditorFor 不可见?

//cshtml

//cshtml.cs代码

0 投票
1 回答
114 浏览

html - Tab键导致位置变化和溢出隐藏元素出现在屏幕上

在此处输入图像描述

这是作为滑块工作的分步表单。

父 div 有样式

孩子们有

活跃的孩子有

被动的孩子有

当第一步处于活动状态并按 TAB 键时,它看起来像:

在此处输入图像描述

不知何故,即使隐藏的步骤左侧设置为 600 像素,定位冲突和其他步骤元素也会进入屏幕。

0 投票
1 回答
53 浏览

c# - 在 Razor 视图中使用列表 - 循环不正确

我一直在努力在我的 Razor View 页面中返回一个列表。我正在将数据传递给我的控制器,该控制器连接到我的服务来为我检索数据。这没有问题。

但是,当我将它传递给我的 Razor View 页面时,它的对象有问题。我最终做了一个 foreach 循环,但有些对象属性不应被视为列表。当我尝试使用“@Html.HiddenFor(m => m.State)”时,它不再起作用,我的结果输出只是页面上的一堆循环。这是我第一次在这里使用列表,希望有人能提出一种方法,让我可以在某些需要它的区域执行 foreach 循环,然后使用 FirstOrDefault,或者对我的属性产生类似效果的东西不想迭代,因为它们只是指标(例如 isEmail = 1)。

[ 控制器 ]

[ 看法 ]

TIA

- 雏菊

0 投票
0 回答
12 浏览

python - 有没有python方法来废弃隐藏的html标签

我尝试通过 Python 从此 HTML 代码中提取数据,但无法提取标签上的隐藏信息

我可以在这里得到一些帮助吗