DNN module development with Razor and C# - c#

I want to add a Razor module to my CMS which was created by DNN. In that razor module I need to show data from database. What would be the best way to do it.
Need a help
Thank you,
Nayanajith

Add an instance of the Razor Host module to a page, and start from there. If you look at the Wiki on dnnsoftware.com, you'll find some more stuff.
For more than complicated uses, that a look at the 2sxc module free at sexycontent.codeplex.com.
If you are planning to get data from the DNN database, you'll want to learn about the DNN api.

I found a simple solution to my problem.
I created a Empty ASP.NET project in visual studio.
Then added Razor page in to that particular project (remember to
delete configuration file).
Then I use connection string and created normal database access class
and added functions which I needed.
Then published the ASP.net Web application and put it in to the DNN
DesktopModule/RazorModule folder and created the module from the DNN
admin.
Now it works fine :)

Related

How to use asp.net vb pages in asp.net c# web application

We have created our website on ASP.NET with C#. But another developer has created her code on VB.NET. Now we have to integrate her pages and code with our existing application.
You can't use VB and C# together within the same Web Application project. What I would recommend is that you convert the VB to C# (or vice-versa) using one of the many automated conversion tools that are available (Telerik has one, for example). Barring that, your next best bet would be to keep them as separate projects and deploy them together to the same site, if that's an option (for example, if each project will be able to have its own set of URLs). If that isn't an option, then you will simply have to bite the bullet and convert one language to the other.
For web application project:
asp.net web application with c# & vb.net both in codebehind
As mentioned by OP in comments, s/he is asking for Web Application projects; so the below is only for website projects:
You don't need to do anything. Just add those .aspx and .aspx.vb pages in your website project. If you are using .NET Framework 2.0 or above, they will compile and the complete website will work.
By the way, if you see, every .aspx page contains the Language attribute in #Page directive which specify the language of the code beside file.

Display External Data in Kentico

I'm using Kentico CMS 7 and there is a way to import external data from Database
http://devnet.kentico.com/docs/devguide/index.html?displaying_data_from_external_database.htm
Displaying data from an external database kentico need to be included in visual studio
so i can customize it
but there is something missing in this article of how to include webproject.sln with some pages already made in kentico based on virtual paths like (Home.aspx - Conatct.aspx - About.aspx) ??
If you mean import the data, then I suggest to use Kentico Import Toolkit.
If you just want to display data from external database, then it depends on what your development model in Kentico CMS is.
Portal engine mode - mentioning the virtual paths for pages like Home.aspx suggests that you use portal engine development. In that case you don't need to write your own code. Use the SQL data source webpart with combination of a viewer webpart like repeater. You can also develop your own webpart to do what you want, see the documentation of how to create a webpart.
ASPX development mode - this mode allows you to leverage your existing knowledge of ASP.NET and write standard code in similar way how it is described in the article.
In situation you would truly need to edit portal engine templates in Visual Studio you need to deploy it from DB to file system. See this article.

How to set custom module as default in orchard cms

I made a custom module in orchard CMS.I want this custom module as startup module when i run my site but orchard always makes home page as start up.how can i make my custom module as Startup in orchard.My module is simple Mvc application using Entity frame work as db .I am pretty new to Orchard i am learning it.Any Help would be appriciated Thanks Advance
In order to steal the home route, you will have to write your own route, and give it high priority. Removing the alias for the current home page will also help.
If your module contains a content type and that content type has an autoroute part then there will be a checkbox in the edit content admin page that says 'Set to homepage'.
You can create lots of different types of modules in Orchard and not all of them contain content types. You can add an autoroute part to a content type that doesn't have one.
It is not true to say "set a module as start up".a module is not an stand alone mvc application, but it is a way of extending existing functionalities.
you can create a ContentType inside your module and orchard will provide the dashboard user with creating of new instance of your type.then user can set this instance as home page content.
to write your own ContentType check here.

Where do I find MVC4 templates for download and how do I install them?

I am somewhat confused. Searched a bunch of ASP.NET related sites but could not find the answer. I must be missing some search word..
I want to find a gallery of MVC4 templates (free/cheap) and apply them to my project. Where do I do that from? I found one codeplex project (http://mvccontribgallery.codeplex.com/), but when I tried applying by copying, there were a bunch of errors (it uses something called SiteMaster, while my project seems to be using something called _layout).
I see a ton of references to people using them, applying them, but I must be missing something very fundamental since I can't even figure out how to find a list of downloadable templates.
What are the simple 1/2/3 steps for finding/getting/installing a template on my MVC4 project?
You should be looking for a suitable HTML template instead of an MVC specific template.
Once you have that, you will need to modify you master template (usually Views/Shared/_layout) to use the HTML and CSS contained within the template you have chosen.
For MVC3 or MVC4 you don't need to download any template. Just install MVC4 in your visual studio 2010 version on higher and then choose option create new project and that is that. See this below screen capture:
Microsoft will provide you the default MVC project architecture or in your term MVC template automatically when you choose any of above option marked in red box.
What do you mean by mvc4 templates? I'm assuming you mean "website template". With MVC you can use any html template, there's no specific template for MVC (that's why you're not finding any of it). You just find any website template and adapt it to mvc context (put css and images under "Content" folder and put html code in _layout and use it like masterpage), not hard to do at all. In fact, so easy to do after you get the idea that no one publish a specific adapted version :)
Follow these steps:
(note: if you have Asp.Net MVC 4, 3 won't install right (for me anyway), so uninstall and install in order).
http://tedgustaf.com/blog/2011/4/installing-asp-net-mvc3-on-visual-studio-2010-sp1/

can I execute an aspx file in a class library and get the result as a string?

I have an c# Class Library where I need some dynamic template based text.
Instead of inventing my own template parser I thought I could create an aspx file in my project that is executed at runtime and, instead of viewing the output in a browser, I want a StreamReader or string object that holds the result.
Is that possible? And if yes, how do I do this?
You're going to struggle more than is necessary with this approach. You'd need an ASP.NET host like IIS.
Personally, I'd recommend an existing template processor. I've heard (on a Hanselminutes or DotNetRocks podcast, I think) that you might even be able to host the T4 system in your application. I'll have a look and see if I've remembered that correctly.
Update
Here's a link on hosting T4 templating in your application.
ASP.Net is designed to be run in a web server engine - you would also have to deploy this to make it work.
Calling ASPX Pages from a Library would be possible (see Cassini WebServer) but I would recommend another tool:
http://www.codeproject.com/KB/cs/T4BasedCodeGenerator.aspx
We use it in our Project - slightly adapted for our needs

Categories

Resources