Can i use mvc2 controls with new Razor engine?
If you mean all the extension methods (ie. Html.ActionLink etc.), yes of course, you'll use #Html.ActionLink() in Razor.
If you mean those Webforms like controls: <mvc:XXX.../> or <asp:XXX .../>: no. These are being rendered by the Webforms ViewEngine and Razor will just output them as HTML.
Related
We have been using asp.net mvc razor technology as a template engine to allow the user to develop razor scripts on the client. we are using this for email template engine.
You can see example at Ricks blog on that
http://www.west-wind.com/weblog/posts/2010/Dec/27/Hosting-the-Razor-Engine-for-Templating-in-NonWeb-Applications
I was wondering if anyone know of a WYSIWYG style editor for the client browser that we can use instead of just a TextArea? Something similar to Visual Studio editor that show razor syntax etc..
Thanks,
Noam
That sounds like an interesting application. I don't think there's an editor that supports the Razor syntax, but you can probably modify an existing client-side rich HTML editor to fit your needs. Here are some listed: http://www.queness.com/post/212/10-jquery-and-non-jquery-javascript-rich-text-editors
Following are the links to MVC HTML editor that you might already know:
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/HTMLEditorExtender/HTMLEditorExtender.aspx
http://mvccontroltoolkit.codeplex.com/
http://richtexteditor.com/mvc/
I have developed a ASP.NET MVC 2 application and I want to put a simple breadcrumbs (sitemap) in each page like this:
Home > Movies > Details
It is equal the URL: http://localhost/home/movies/details
How can I achieve it? I would like to put it in my master page.
Thanks!
I would recommend using MVCSiteMapProvider. It's available as a NuGet package.
It can be used to generate breadcrumbs (which you are probably asking about) and also site maps.
MvcSiteMapProvider is, as the name
implies, an ASP.NET MVC
SiteMapProvider implementation for the
ASP.NET MVC framework. Targeted at
ASP.NET MVC 2, it provides sitemap XML
functionality and interoperability
with the classic ASP.NET sitemap
controls, like the SiteMapPath control
for rendering breadcrumbs and the Menu
control.
Based on areas, controller and action
method names rather than hardcoded URL
references, sitemap nodes are
completely dynamic based on the
routing engine used in an application.
The dynamic character of ASP.NET MVC
is followed in the MvcSiteMapProvider:
there are numerous extensibility
points that allow you to extend the
basic functionality offered.
If it is always equal to the URL, the absolute simplest thing would be to make use of that by using something like this:
var menuitems = Request.Url.AbsolutePath.Split("/".ToCharArray(),
StringSplitOptions.RemoveEmptyEntries);
menuitems would now contain the menu items you need to perform a simple foreach loop and build your menu.
Is it possible to use Mvc3 razor scripts inside mvc 2 aspx page view and mvc 2 ascx control view?
I'm not sure what you are asking. What do you mean by "razor scripts"? Do you mean a razor partial? In that case, then yes. An aspx view can call a razor partial just fine (and vice versa).
If you mean embed a chunk of razor inside of an aspx/ascx, then no.
Razor is intended for MVC 3, but people have successfully gotten it working in MVC 2. Such as this question: How to Download Razor View Engine
In short No. You can use Razor and the WebForms view engines alongside each other, but you cannot mix them in the same view.
Besides, as far as I know, you can't use Razor with ASP.NET MVC 2 either although I'm not 100% sure on that last one.
I have the MVC Telerik grid with one column as a hyper link. Whenever the user clicks on this link, I am loading a partial view using Ajax.
Within this partial view I have a Telerik MVC tabstrip control. The problem which I am currently facing is that I am not able to switch between the tabs of this tabstrip when it is rendered. Probably it is not able to reference its JavaScript files as it is loaded via Ajax.
I have already referred to the Telerik article of registering JavaScript files using the script registar:
<%= Html.Telerik().ScriptRegistrar()
.DefaultGroup(group => group
.Add("telerik.common.js")
.Add("telerik.component.js")
%>
However, the difference in this example is that here the tabstrip control is not loaded using Ajax. Only the content is loaded using Ajax whereas in my case I am loading the tabstrip control using Ajax.
How can I fix this problem?
I resolved it! If you face such an issue, refer to Telerik Extensions for ASP.NET MVC Manual.
i'm not sure, but didn't asp.net mvc 2 provide a way to create strong typed tags?
Michel
ASP.NET MVC Futures contains a strongly typed action link. It's implimentation is a bit wacky though (you can read more about that here). Personally I would go with the T4 solution.
Using the T4MVC Templates, you can use view code like this (ASPX engine)
<%: Html.ActionLink("About Us", MVC.Home.About()) %>
More here: http://mvccontrib.codeplex.com/wikipage?title=T4MVC