开发者

Special methods and tricks in ASP.NET MVC? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

Please tell me your favorite trick and tips to me. I want to collect so much knowledge as I can. And I think it's the best way to hear it from experts and amateur developers.

1. HTML FORM Tag + Attribute "multipart/form-data" and HttpPostedFileBase

I cloud tell you something about htm开发者_如何学Gol form tag. If you use form tag in MasterPage of your MVC project. And you need in one only View one extra attribute for Image Uload like: "multipart/form-data". Be carefull, look at your Code-Source, because you could have 2 Form tags and your parameter of type HttpPostedFileBase can always be null. I solved it so: Activated "multipart/form-data" in form just if this View will called. I did it in codebehind and I know it is not nice solution.

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    Form.Enctype = "multipart/form-data";
}


Using Html.Serialize helper method to persist view models between pages and of course MVCContrib.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜