English 中文(简体)
B. 保持MVC状态 3
原标题:Maintaining state in MVC 3

I am simply devloping entry form using mvc 3. I have many text boxes,radio button, lables. so while post back data from view to controller it loses entered data. how to retain this for all postbacks? is there any mvc mechanisam avialable by default? which means by enabling some properties do we command mvc to handle state by itself?

i 无意发送电文。 除此以外,哪些缺省机制可在 mvc3中使用?

Update:

@using (Html.BeginForm())
{
<table>
    <tr>
        <td>

            @Html.TextBox("txtTitle")
@Html.CheckBox("chkOption")
        </td>
        <td>               
            @Html.TextBox("txtDetails")
@Html.DropDownList("drpList")
        </td>
        <td>
            <input type="submit" value="Cancel" name="action" />
            <input type="submit" value="Create" name="action" />

        </td>
    </tr>
</table>
}

如何保持所有员额的入门和选定价值的状况?

最佳回答

它希望你能创建<代码>Model,并使用@Html.TextBoxFor(),@Html.CheckBoxFor(@Html.DropdownListFor() ,而关于你的模型特性。

然后,你将采用一种类似名称的行动方法,与<代码>[HttpPost]属性以及模型作为参数。 然后,如果形式状况有效,你将能够对试图提交的形式进行验证,并处理模式。

我研究强烈分类的观点、模式,可能通过一些在线辅导。

下面的链接似乎是一个很好的指导,它有几页长的时间,但应该走到你需要开始的一切。

http://www.asp.net/mvc/tutorials/ap-started-with-aspnet-mvcs/intro-to-aspnet-mvc-3

问题回答

您可使用Session,在多个后台上坚持状态。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签