ASP .NET Reques.Form DropDownlist 奇怪的行为

发布于 2024-10-08 02:54:27 字数 595 浏览 0 评论 0原文

我在获取下拉列表的选定值时遇到问题。

我的视图源看起来像这样:

<div class="editor-field">  
  <select class="list" id="DivisionesLists" name="DivisionesLists">
    <option value=""> -- Seleccione -- </option>
    <option selected="selected" value="1">COORPORATIVO</option>
    <option value="2">MANUFACTURA</option>
  </select>
</div>

我的控制器:

string s = Request.Form["DivisionesLists"];

问题是 Request.Form["DivisionesLists"] 返回“1,1”而不是“1”(这是下拉列表的实际选定值)。

可能发生什么情况?

谢谢你!!!

I have an issue getting the selected value of a dropdownlist.

My view source looks like this:

<div class="editor-field">  
  <select class="list" id="DivisionesLists" name="DivisionesLists">
    <option value=""> -- Seleccione -- </option>
    <option selected="selected" value="1">COORPORATIVO</option>
    <option value="2">MANUFACTURA</option>
  </select>
</div>

And my controller:

string s = Request.Form["DivisionesLists"];

The problem is that Request.Form["DivisionesLists"] returns "1,1" instead of just "1" (which is the actual selected value of the dropdownlist).

What may be happening?

Thank you!!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天暗了我发光 2024-10-15 02:54:27

它还可能会发布一些附加数据,如果您选择第一个数据会发生什么,它会回发什么?它会用逗号回发任何内容吗?

它可能是一个重复的控件...尽管像 Html.CheckBox 操作方法一样:它呈现复选框控件和一个隐藏字段,该隐藏字段表示当复选框不存在时的值;当检查为 true、false 时访问该值。

HTH。

It might also be posting some additional data, what happens if you select the first one, what does it post back? Does it post anything back with a comma?

It could be a duplicate control... though like Html.CheckBox action method: it renders the checkbox control and a hidden field that represents the value when the checkbox isn't there; accessing the value when its checked is true,false.

HTH.

來不及說愛妳 2024-10-15 02:54:27

如果选择不是多重选择,我认为您在页面上有另一个具有相同名称属性的控件(输入或选择)。

If the select isn't a multiple select I think you have another control (input or select) that have the same name attribute on the page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文