data annotations - Orchard Module - How to return strongly typed Model rathen than dynamic from Driver -


i created contactus module sends email when user click on submit button.

everything works perfectly. however, curious if possible return typed model rather dynamic class.

for example, following drivers\contactusdriver.cs display function:

protected override driverresult display(contactuspart part, string displaytype, dynamic shapehelper) {         return contentshape("parts_contactus",             () => shapehelper.parts_contactus(                  name: part.name)); } 

as can see, above returning dynamic parts_contactus.

now, here's snapshot of views\parts\contactus.cshtml:

@model dynamic  @using (html.beginform("send", "contactus", new { area = "contactus" }, formmethod.post)) {     <fieldset>         <legend>contact us</legend>         <div id="contact-us" class="area">             @html.textbox("name", "")         </div>         <div id="submitarea" class="button">                    <input type="submit" value="submit message">         </div>     </fieldset> } 

as can see above view bound @model dynamic. result, have following

@html.textbox("name", "") 

is there way can bind model contactusmodel , following instead?

@html.textboxfor(m => m.name) 

particularly, interested can write jquery validation dataannotation attribute.

it's possible. provide desired model type first argument when creating shape:

protected override driverresult display(     contactuspart part,      string displaytype,      dynamic shapehelper) {     return contentshape("parts_contactus",         () => shapehelper.parts_contactus(typeof(myclass), name: part.name)); } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -