Skip to content

Allows the use of Razor in WebForms, for simple model and templates.

Notifications You must be signed in to change notification settings

bradbamford/WebFormsRazor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebFormsRazor

Allows the use of Razor in WebForms, for senarios where you want to simply generate clean HTML without the need for server controls.

How to Use:

Rendering the Template is as simple as calling RazorTemplate.Render() passing in your model and path to the razor file.

// Get the generated Html
var html = RazorTemplate.Render(myModel, "~/template.cshtml");

// add the html to a control.
Literal1.Text = html;

The only hurdle is razor files must inherit from RazorWebPage.

@inherits WebFormsRazor.RazorWebPage<myModel>

Notes

The idea for this came directly from the way DotNetNuke is doing the exact same thing except inside it's own framework using DotNetNuke.Web.Razor. I wanted to be able to do the same thing in standard ASP.NET WebForms ASPX pages. However, I could never find a way to render html using just a razor file and a model for model binding. So, this is my attempt to extract out how DNN was doing it, but for use in a standard ASPX page.

About

Allows the use of Razor in WebForms, for simple model and templates.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages