小编lar*_*ole的帖子

ModelState.IsValid不排除必需的属性

我试图排除一个必需的属性(密码),因此模型状态不会验证该属性,但由于某种原因,即使我尝试排除它,它仍然会验证.

控制器:

    [Authorize, AcceptVerbs(HttpVerbs.Post)]
    public ActionResult _Edit(int id, [Bind(Exclude = "Password")]FormCollection collection)
    {
        var user = Proxy.GetUser(id);

        TryUpdateModel(user, null, null, new[]{"Password"});

        if(!ModelState.IsValid)
            return PartialView(user);

        Proxy.UpdateUser(user);
    }
Run Code Online (Sandbox Code Playgroud)

视图:

   ...
   <tr>
       <td class="label">
           <label class="row_description" for="Password"><%= S._("Password")%></label>
       </td>
       <td>
           <%= Html.Password("Password", null, new { @class = "row_input" })%>
           <%= Html.ValidationMessage("Password", "*")%>
       </td>
   </tr>
Run Code Online (Sandbox Code Playgroud)

用户(使用dataannotation):

[Required]
public string Password { get; set; }
Run Code Online (Sandbox Code Playgroud)

我使用的是VS2008,MVC2,firefox

也许我只是累了,看不到它.任何帮助表示赞赏

asp.net-mvc

8
推荐指数
1
解决办法
1万
查看次数

如何使用jqgrid和http方法POST将额外的参数传递给服务器?

我正在做类似这篇文章中的人:有没有办法在jquery jqgrid中以编程方式设置过滤器?

我正在使用http方法POST从我的MVC2项目中获取数据,我看到你可以使用GET这样添加一个参数:

You can modify the url that jqGrid calls, and add the filter option to the querystring, then handle it on the server side.

    $(link).click(function(){

    $(".mygrid").jqGrid('setGridParam',{url:"server.php?useMyFilter=1"})
    });
Run Code Online (Sandbox Code Playgroud)

如何使用POST添加额外的过滤器参数?

asp.net-mvc jqgrid

4
推荐指数
1
解决办法
2650
查看次数

标签 统计

asp.net-mvc ×2

jqgrid ×1