首页 > 代码库 > 【每日更新】【MVC工作遇到的问题】

【每日更新】【MVC工作遇到的问题】

 

4.MVC的Action返回操作结果

OperateResult
            var reqMsg = MessageObject.Create(MessageCodes.FimSubmitCheck, model);            var result = ServiceClient.Instance.CallServer(reqMsg).GetValue() as OperateResult;            return Json(result, JsonRequestBehavior.AllowGet);

 

3.MVc中要想把标签的值提交到后台必须 设置 标签input的Name,必须要和 字段名称 一致! 否则无法提交到后台!

Model.TianXieList  对象的集合属性 进行页面绑定,确保input的 Name不同,才能提交到后台。
@foreach (var ss in Model.TianXieList)            {                int ll=0;                                <tr>@Html.HiddenFor(modelitem=>ss.TianXieId)                <td>@Html.TextBoxFor(modelitem=>ss.DataSort,new { name="TianXieList["+ll+"]", style="width:30px;" })</td>                <td>@Html.TextBoxFor(modelitem=>ss.N0,new { name="TianXieList["+ll+"].N0", style="width:30px;" })</td>                <td>@Html.TextBoxFor(modelitem=>ss.N1,new { name="TianXieList["+ll+"].N1", style="width:30px;" })</td>                <td>@Html.TextBoxFor(modelitem=>ss.N2,new { name="TianXieList["+ll+"].N2", style="width:30px;" })</td>                <td>@Html.TextBoxFor(modelitem=>ss.N3,new { name="TianXieList["+ll+"].N3", style="width:30px;" })</td>                <td>@Html.TextBoxFor(modelitem=>ss.N4,new { name="TianXieList["+ll+"].N4", style="width:30px;" })</td>                <td>@Html.TextBoxFor(modelitem=>ss.N5,new { name="TianXieList["+ll+"].N5", style="width:30px;" })</td>                 <td>@Html.TextBoxFor(modelitem=>ss.NAvg,new { name="TianXieList["+ll+"].NAvg", style="width:30px;" })</td>                <td>                                     <img src="~/Images/add1.png" class="addPic" />                    <img src="~/Images/delete.png" class="deletePic" />                                    </td>

 

 

2.MVC页面访问某个Action并传参

@Url.Action生成url
var url = ‘@Url.Action("DocMgr")‘ + ‘?id=‘ + row.ID + ‘&ApplyCode=‘ + row.ApplayCode;            var url = ‘@Url.Action("EditContract", "Contract")‘ + ‘?ApplayInfoID=‘ + row.ID;

 

 

1.MVc的Ajax请求之后无法更新ParticalView的解决办法:

父页面:

id="UpdfromBRQuery"
   <div id="UpdfromBRQuery" class="panel panel-default">                        <div class="panel-heading">                            <table>                                <tr>                                    <td>                                        <span class="panel-title">                                            <strong>                                                <a data-toggle="collapse" data-parent="#accordion" href="#10" tag="collapse12">特殊名单查询</a>                                            </strong></span>                                    </td>                                    <td>                                        <input type="button" value="查询"  class="btnSearch" onclick="submit(‘fromBRQuery‘)""/>                                    </td>                                </tr>                            </table>                        </div>                        <div id="collapse12" class="panel-collapse collapse in">                            <div class="panel-body">                                @{                                    Html.RenderAction("BaiRongQuery");                                }                            </div>                        </div>

 

 

子页面:

new AjaxOptions { UpdateTargetId="UpdfromBRQuery"}
using (Ajax.BeginForm("BaiRongQuery", "ThreePartyInfo",new { timestamp= DateTime.Now.ToString("yyyyMMDDHHmmssss") }, new AjaxOptions { UpdateTargetId="UpdfromBRQuery", OnSuccess = "oncomplete({ Flag:1,Description:‘查询成功‘})" }, new { id = "fromBRQuery" })){     <div class="form-group">    //此处需要更新数据}

 

提示:

1.加个timestamp参数在提交的数据里,防止缓存!

2.请在ajaxoption里面设置“UpdateTargetId”属性来制定 ajax返回的数据需要更新的 Div。

 

【每日更新】【MVC工作遇到的问题】