【问题标题】:pass value of a Ext.NET hidden field to Action method as a parameter将 Ext.NET 隐藏字段的值作为参数传递给 Action 方法
【发布时间】:2013-07-17 05:04:18
【问题描述】:

如何访问 Action 方法参数中的隐藏字段值 请参考以下代码

Url.Action("action","controller",new {para_name=hidden_field_value})

【问题讨论】:

  • 我已经获取了@ViewBag.Item 中的值,我想将此值作为参数分配给上面的操作,并且不想将其作为查询字符串参数发送
  • 您将 ViewBag.Item 中的值分配给隐藏字段,然后您想将其作为参数传递给 Url.Action?
  • 没有。我在 ViewBag 和隐藏字段中都获得了价值。尝试访问两者都没有成功
  • 只有一种方法可以做到这一点,检查我的编辑

标签: javascript jquery asp.net ext.net


【解决方案1】:

编辑

您在评论中的代码仅将值“country”分配给 ViewBag.Country,这意味着它不起作用。

同样,您唯一的解决方案是使用以下方法

var url = '@Url.Action("action", "controller")?country=' + Ext.getCmp("CmbCountry").value

你说

我想将此值作为参数分配给上面的操作和 不想将其作为查询字符串参数发送

但这正是Url.Action 方法所做的,如果你观察Url.Action 方法的结果,你会发现它是一回事

【讨论】:

  • 我试过了,但 ViewBag.Item 返回的是名称而不是值
  • 这是我的代码var country=""; var getCmbCountry = function () { country = Ext.getCmp("CmbCountry").value; App.hdnCountry.value=country; @(ViewBag.Country="country") };
【解决方案2】:

得到解决方案,首先将值设置为getCmbCountry()函数上方的隐藏字段 然后将此隐藏字段值作为EXT.NET StoreParameter 发送如下

.Params(new StoreParameter { Name="countryCode", Value="App.hdnCountry.getValue()", Mode=ParameterMode.Raw})

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-04
    • 1970-01-01
    • 1970-01-01
    • 2014-08-14
    • 1970-01-01
    • 2017-02-05
    • 2020-11-16
    相关资源
    最近更新 更多