Click here to Skip to main content
15,561,817 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
See more:
hello everybody
well i've been using MVC 2 and got the idea how to do things i wanted to do but than i moved to MVC 4 and when i faced Razor and cshtml files i understood that we can't use webform controls on those files (such us Datagrids,dropdown menus...etc). tried to to create everything using razor but i faced this issue and my question is:

What am i missing here,can we or can't we use webforms controls in razor (not Html helper),if yes would you give me some good articles to read because my googling wasn't satisfying?
Jameel VM 24-May-13 12:17pm    
you can't add webform control in Razor view.Why you are doing this?

1 solution

You cannot use webforms controls when using MVC/Razor.

I would take a look at the following links to get a better understanding of what MVC/Razor is.

MVC 3 Specific[^]

Difference between ASP.Net Engine and Razor Engine - Question[^]

Introducing Razor[^]

MVVC 4[^]

Web Forms vrs MVC[^]

Syntax Comparison with code in Web Forms and doing same in MVC[^]

An Architectural View of the ASP.NET MVC Framework[^]

Hopefully this helps with you obtain a better understanding MVC/Razor.
Share this answer
tux@ddictor 24-May-13 19:14pm    
thanks a lot for your answers,both of i got the idea,with MVC/Razor we use Html to do eveyrything(plus C# codes),so if wanted to use a datagridview i have to use html tags to come up with something looks like a datagrid(such as using tables or divs..etc).i came from WPF/Winforms background to ASP.NET Webforms/MVC2 so believing the idea that i don't have a toolbox with a lot of controls where i can just drag and drop them into my pages in razor was actually hard for me to swallow....Microsoft teached us laziness :)
David_Wimbley 25-May-13 15:53pm    
See i actually like the razor engine because i feel like i have more control over what is going on.

say you have a list of programming languages:

List<string> list = new List<string>();

so in razor, to get this into a gridview all you would have to do is

<th>Language Name</th>
@foreach(var lang in list)

Of course there are TONS of html helpers for razor that would make up your "tool box". For example, the above "data grid view" that i've showed, there is actually a html helper to build a grid in the mvc framework.

Here is another link for html helpers/building your own:

I find myself building some html helpers so that way im not repeating the same HTML over and over, but for the most part everything you would write HTML (like the above sample) has some sort of helper that razor-fys it.

I know what you mean, i did the oppositve, i went from web platform to winforms/wpf so i was use to over complicating things.
tux@ddictor 25-May-13 23:05pm    
Well said David.thanks for all those links and yes helpers Help a lot,i started with some basic ones to understand the idea,that's was nice.

Thank you again for everything.wich you happy life.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900