Click here to Skip to main content
15,882,163 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So this is the view :

@model CMSFC.Models.Page

@{
    
    Layout = "~/Views/Shared/_Layout.cshtml";
}





    @{



        Response.Write(Model.Template);
    }



It renders a html table (saved in Template column) from database , with header footer body and so on .. But this renders a very small table on the top left corner of the application , i want to render that html table on the entire screen of view .

What I have tried:

--------------------------------------
Posted
Updated 6-Sep-17 1:42am
Comments
[no name] 6-Sep-17 5:22am    
Generating HTML in your controller from something stored in the database seems odd to me. Usually your model should contain some kind of data that can be mapped to a view.

Unless there's some kind of unusual need to do this, you'd be better off having your HTML in views (a partial view for specific table layouts may be more appropriate).
ddgjgj 6-Sep-17 5:24am    
can you provide me any helping code about that ?
[no name] 6-Sep-17 6:48am    
There are some good articles online giving introductions to ASP.NET MVC..

http://www.tutorialsteacher.com/articles/how-to-bind-model-to-partial-view
https://www.codeproject.com/Articles/710776/Introduction-to-ASP-NET-MVC-Model-Binding-An-Absol

1 solution

On a side note if that Mode.Template is the raw HTML content which you want to write on the browser, then I would follow a different approach,
HTML
@Html.Raw(Model.Template)

This would render the HTML content from database, and still follow the MVC semantics and processes of generating Layout and filling the View information. It is not a good approach to go a Response.Write(), in any case. Response.Write was used as alternate to the <% variable %> approach of Classic ASP and sometimes in ASP.NET Web Pages, but in ASP.NET MVC you need to follow the MVC pattern to better make use of the services and features provided in this framework, which are provided by the @Html helpers.

how to use @html.raw | The ASP.NET Forums[^]
Is Response.Write in ASP.NET views a bad idea? - Stack Overflow[^]

Edit
Quote:
But this renders a very small table on the top left corner of the application , i want to render that html table on the entire screen of view .
You can apply the styling to the table itself as well. But it is still better to follow the semantics. :-)
 
Share this answer
 
v3
Comments
ddgjgj 6-Sep-17 7:59am    
U Genius , or somethin`. Thanks.

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