I've written an Html Helper called DetailsForm to reduce repetition when displaying fields in a view. Within a view - actually a partial view, ascx file - I can refer to it like this:
Storyboard.Helpers.DetailsForm.LabelAndData(Html, m => m.id)
But would like to refer to it like this:
LabelAndData(Html, m => m.id)
A 'using' directive doesn't seem to b开发者_如何学Goe allowed in the ascx file. Is there an equivalent?
you should be able to import the namespace in the top of your ascx, like so:
<%@ Import Namespace="Storyboard.Helpers" %>
UPDATE
Reading your comment, I'm guessing your helper looks something like:
public static Something LabelAndData(this HtmlHelper html, .....
in which case you would call it like this in your view:
Html.LabelAndData(m => m.id)
Hope that helps!
if you use the same namespace as the Default Html Helpers which is System.Web.Mvc.Html
of MVC for the one that you created, you don't need to reference your created Html Helper anywhere.
精彩评论