1

Is it possible to use MVC Helpers in webpages (cshtml) ?

I'm trying out some controls from infragistics, and would like to use the html helper method to create the grid (avoiding some javascript) but I can't seem to get any intellisense.

No, I'm unsure if it should work?

Update: I want to use the following line:

@Html.Infragistics().Grid(....

inside my MyWebPagesPage.cshtml

Thanks for any help

Larsi

Borislav T
  • 619
  • 4
  • 20
Larsi
  • 4,654
  • 7
  • 46
  • 75
  • If you have Resharper installed you must turn off the its intellisense to use it in the Razor files. Other then that you should be able to put @HtmlHelper.(whatever) and get it working. http://stackoverflow.com/questions/4710853/using-mvc-htmlhelper-extensions-from-razor-declarative-views – Tony Dec 21 '11 at 14:01

2 Answers2

1

You should be able to, just add @using infrajistics.namespace

You could also add the namespace to ur web.config namespaces section so that you don't have to add the @using in each view

Bassam Mehanni
  • 14,796
  • 2
  • 33
  • 41
  • Hmmm... yes it turns out that it is that simple. The intellisense starts after entering @Html.Infragistics(). Thanks alot! – Larsi Dec 21 '11 at 14:16
0

There are no helper method that would render Infragistics controls. Please take a look at this page, it has detailed instructions of using Infragistics controls in MVC pages.

There are some limitations though. Infragistics doesn't have separate controls for MVC, they are simply making their asp.net controls available, but there's a drawback.

As long as you focus on areas of the controls that do not initiate post backs or rely on ViewState, you soon find many behaviors and functions that work perfectly in an ASP.NET MVC application.

Sample usage would be:

<%@ Register Assembly="Infragistics.Web.Mvc" Namespace="Infragistics.Web.Mvc" TagPrefix="cc1" %>
<%@ Register Assembly="Infragistics35.Web.v9.1, Version=9.1.20091.1015, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"
    Namespace="Infragistics.Web.UI.GridControls" TagPrefix="ig" %>

<ig:WebDataGrid ID="wdg" 
        runat="server" Width="50%" 
        EnableViewState="false">
    </ig:WebDataGrid>

No MVC helpers involved.

Tomislav Markovski
  • 12,331
  • 7
  • 50
  • 72
  • Thanks for looking into this, but I don't need the webforms control on a mvc page. It's rather opposite. I want the jQuery grid of infragistics (igGrid) that has a mvc helper, and use that mvc helper in a webpages page. – Larsi Dec 21 '11 at 14:04
  • That would be even less possible, since ASP.NET will not process MVC rendering logic. – Tomislav Markovski Dec 21 '11 at 14:07
  • You could use `<%= System.Mvc.HtmlHelper.TextBox("my text") %>`, but that only comes down to rendering the html. – Tomislav Markovski Dec 21 '11 at 14:09
  • For MVC and using the jQuery grid, look at the following topic: http://help.infragistics.com/NetAdvantage/jQuery/Current/CLR4.0?page=igGrid_Developing_ASP_NET_MVC_Applications_with_igGrid.html – alhalama Apr 09 '12 at 14:56