Now Available - ASP.NET MVC 3 Razor Demos Online!

ASP.NET Team Blog
25 July 2011

DevExpress_MVCGood news for you ASP.NET MVC 3 Razor View Engine fans.

We've updated all of our online demos to the Razor View Engine code!

Check our the updated code online at http://mvc.devexpress.com

Available in v2011 vol 1.6

A local version of our MVC demos is available now in the DXperience v2011 volume 1.6 minor release.

Download it here: http://devexpress.com/ClientCenter/Downloads/

How To Use In MVC 3

The DevExpress ASP.NET MVC Extensions are fully compatible with ASP.NET MVC 3 Razor view engine now. Check out these resources to learn more about using:

Here's a preview of the Razor demo code:

@using System.Text.RegularExpressions

@Html.DevExpress().GridView(
    settings =>
    {
        settings.Name = "gvDataBinding";
        settings.CallbackRouteValues = new { Controller = "GridView", Action = "DataBindingPartial" };
        settings.Width = Unit.Percentage(100);

        settings.SettingsText.Title = "DevExpress on Twitter";
        settings.Settings.ShowTitlePanel = true;
        settings.Settings.ShowStatusBar = GridViewStatusBarMode.Visible;
        settings.SettingsPager.Mode = GridViewPagerMode.ShowAllRecords;
        settings.SettingsPager.AllButton.Text = "All";
        settings.SettingsPager.NextPageButton.Text = "Next >";
        settings.SettingsPager.PrevPageButton.Text = "< Prev";

        settings.SetStatusBarTemplateContent(c =>
        {
            ViewContext.Writer.Write(
                "<span id=\"lblLoading\">&nbsp;</span>"
            );
        });
        settings.SetEmptyDataRowTemplateContent(c =>
        {
            ViewContext.Writer.Write(
                "Sorry, the twitter server is not available this time."
            );
        });
            
            
        settings.CustomColumnDisplayText = (sender, e) => {
            if(e.Column.FieldName != "Text") return;

            string displayText = (e.Value != null) ? e.Value.ToString() : "";
            TweetsDemoReplaceItem[] replaceItems = new TweetsDemoReplaceItem[] { 
                new TweetsDemoReplaceItem{
                    RegEx = new Regex("http://[^\\s()]+"),
                    ReplaceDelegate = (text, match) => { return text.Replace(match.Value, string.Format("<a href=\"{0}\">{0}</a>", 
                        HttpUtility.HtmlEncode(match.Groups[0].Value))); }
                },
                new TweetsDemoReplaceItem{
                    RegEx = new Regex("(^|[^\\w])@(\\w+)"), 
                    ReplaceDelegate = (text, match) => { return text.Replace(match.Value, string.Format("{0}<a href=\"http://twitter.com/{1}\">@{1}</a>", 
                        match.Groups[1], HttpUtility.HtmlEncode(match.Groups[2].Value))); }
                },
                new TweetsDemoReplaceItem{
                    RegEx = new Regex("(^|[^\\w/&?])(#\\w+)"), 
                    ReplaceDelegate = (text, match) => { return text.Replace(match.Value, string.Format("{0}<a href=\"http://twitter.com/search?q={1}\">{2}</a>", 
                        match.Groups[1], Url.Encode(match.Groups[2].Value), HttpUtility.HtmlEncode(match.Groups[2].Value))); }
                }
            };

            foreach(TweetsDemoReplaceItem replaceItem in replaceItems) {
                MatchCollection matches = replaceItem.RegEx.Matches(displayText);
                foreach(Match match in matches)
                    displayText = replaceItem.ReplaceDelegate(displayText, match);
            }
            e.DisplayText = displayText;
        };
                                
    }).Bind(Model).GetHtml()

This the razor code for the partial view of our MVC GridView's Twitter Databinding Demo.

Available Now!

Our new MVC 3 Razor demos of our ASP.NET MVC Extensions are available now.

Download the minor release of DXperience v2011 vol 1.6 and see for yourself.

Are you looking forward to the new MVC 3 Razor demos? Drop me a line below, thanks.

 

Build Your Best - Without Limits or Compromise

Try the DevExpress ASP.NET MVC Extensions online now: http://mvc.devexpress.com

Read the latest news about DevExpress ASP.NET MVC Extensions: http://dxpr.es/ov1tQa

Download a free and fully-functional version of DXperience now: http://www.devexpress.com/Downloads/NET/

Follow MehulHarry on Twitter

Free DevExpress Products – Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We’ll be happy to follow-up.
Glen Harvy
Glen Harvy

Hi Mehul,

Sounds good however I would also like to see a tutorial on using a common MVC 3 DX control in a simple (and I mean SIMPLE) MVC 3 project. The tutorial should be able to be adapted to cover the ability to allow the student to drop in any MVC 3 DX control.

The tutorial should not assume that the student is an expert or well experienced in using MVC 3 nor DX Controls.

This would give a prospective DX purchasers an opportunity to actually see their own handiwork in action and also display how easy it is to create MVC 3 projects using DX Controls.

Demo's are all well and good but generally DX demo's assume the reader is already well experienced in what the demo is all about, how to create  the appropriate project etc etc. Hacking your demo's so that you can learn and use your controls is not always an easy task I'm afraid.

15 July 2011
Mehul Harry (DevExpress)
Mehul Harry (DevExpress)

Glen,

Thanks for the feedback. We're working to bring some new demos for 11.2 that will help showcase our ASP.NET tools better. Also, we're also targeting to improve the video training material we have.

Could you please email me when you have chance please? I'd like to discuss your ideas: mharry at devexpress.com

Thanks again.

18 July 2011
David Chai Kam Fook
David Chai Kam Fook

This is great news. But, unfortunately the initial load is very sloooow compared to WebForm version

26 July 2011
Junior Thurler
Junior Thurler

I think that this is a problem with DevExpress. All the demos is excellent (not just in Asp.NET but all the plataforms).

But if you want to do something equals you will have some difficult because the demos are so well written with a lot of modulues, classes and so I think that just the support team is able to understand what is happening behind of scenes.

I suggest that DevExpress create a team specialized just in produce intermediate videos and other types of material focusing the intermediate users, showing how to make things like the features of the demos and the best practices in all the plataforms. I miss a Best Practices material to guide me in the development using the DevExpress components.

But I really love DevExpress components and I use it on ANY program that I do... Since 1999...

26 July 2011
Mehul Harry (DevExpress)
Mehul Harry (DevExpress)

Rahmat,

Thanks and could you please explain how is the MVC version slower for you?

26 July 2011
Mehul Harry (DevExpress)
Mehul Harry (DevExpress)

Junior,

Thanks for your support. In the next release, we'll have some samples sites which may help you. The current feature demos are designed to showcase features. And the MVC demos actually follow all the 'proper' MVC guidelines for good separation. :)

Hope that helps, thanks.

26 July 2011
Ralph Jansen
Ralph Jansen

Hello Mehul,

We use all the DevExpress components for a couple of years now. I'm now evaluating what the differences are between the asp .net webforms components and the MVC components. I think you gues did a good job with 11.1 release.

I made a sample project with the Razor engine and after a couple of times trying, I could get a GridView to work. The only problem is that I couldn't found a way to store the settings of the GridView in a XML format. We want to recreate an application to web. It is now build in Winforms. We need to store it in xml format and not in session because our users work in a Citrix envirement. Can you help me with that?

27 July 2011
Mehul Harry (DevExpress)
Mehul Harry (DevExpress)

Ralph,

Sure but I recommend you contact our support and they can help you.

28 July 2011
Georges Bessis
Georges Bessis

Hello,

I always appreciated your work, and will continue for this way to propose nice general clear samples for new techniques.

The problem is : here we use much more VB.Net than C#.

Do you have any plan to provide ypur samples in VB..NET?

Thanks for the excellent products.

Georges

28 July 2011
Mehul Harry (DevExpress)
Mehul Harry (DevExpress)

Hi Georges,

Thanks.

Unfortunately, we don't have many demos for VB.NET but we may in the future. There are some CodeCentral demos for VB.NET MVC now.

However, if you need help with any particular demo then please contact our excellent support team and they will glady help you with the C# to VB.NET conversion.

Thanks.

29 July 2011

Please login or register to post comments.