asp.net - How to make a custom strongly typed html helper method? -


now found out how create custom html helpers

using system; namespace mvcapplication.helpers {   public class inputlhelper {     public static string input(this htmlhelper helper, string name, string text) {        return string.format("<input name='{0}'>{1}</input>", name, text);     }   } } 

now how turn typed helper method inputfor in framework?

i don't need html.textboxfor method, know exists. curious in how implement behavior myself , used simple example.

ps. looking in mvc source code couldn't find trace of mysterious textboxfor. found textbox. looking @ wrong code?

here can find asp.net mvc 2 rtm source code.

if @ inputextensions class inside system.web.mvc.html namespace find following code

[suppressmessage("microsoft.design", "ca1006:donotnestgenerictypesinmembersignatures", justification = "this appropriate nesting of generic types")] public static mvchtmlstring textboxfor<tmodel, tproperty>(this htmlhelper<tmodel> htmlhelper, expression<func<tmodel, tproperty>> expression) {     return htmlhelper.textboxfor(expression, (idictionary<string, object>)null); }  [suppressmessage("microsoft.design", "ca1006:donotnestgenerictypesinmembersignatures", justification = "this appropriate nesting of generic types")] public static mvchtmlstring textboxfor<tmodel, tproperty>(this htmlhelper<tmodel> htmlhelper, expression<func<tmodel, tproperty>> expression, object htmlattributes) {     return htmlhelper.textboxfor(expression, new routevaluedictionary(htmlattributes)); }  [suppressmessage("microsoft.design", "ca1006:donotnestgenerictypesinmembersignatures", justification = "this appropriate nesting of generic types")] public static mvchtmlstring textboxfor<tmodel, tproperty>(this htmlhelper<tmodel> htmlhelper, expression<func<tmodel, tproperty>> expression, idictionary<string, object> htmlattributes) {     return textboxhelper(htmlhelper,                             modelmetadata.fromlambdaexpression(expression, htmlhelper.viewdata).model,                             expressionhelper.getexpressiontext(expression),                             htmlattributes); } 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -