Is it possible that I reserve a asp.net code in db and load it at runtime. the asp.net code contains server side tags like Text='<%# Eval("Description") %>'
views:
50answers:
1
+3
A:
You can write to an aspx, plugging in what you want and then build the page using:
BuildManager.CreateInstanceFromVirtualPath("~/MyPage.aspx",typeof(Page));
You'd need to wrap that when getting your HttpHandler:
var p = BuildManager.CreateInstanceFromVirtualPath("~/MyPage.aspx",typeof(Page));
HttpContext.Current.Handler =p;
(BuildManager is in System.Web.Compilation
)
That's just an idea....but I wouldn't do this, as you're going to pay the compilation cost every time (which is really high compared to pretty much any other operation), and you'd need to bump your application files writes before restart (default 15).
Short answer: Yes you can do this, but I wouldn't. There's most likely a much better way to achieve your goal, maybe if you gave a bit more background, we can provide a much better solution.
Nick Craver
2010-02-28 12:10:32
I want to give this ability to user that make a returned data form as a grid.
masoud ramezani
2010-02-28 13:05:59
@masoud ramezani - Does the grid just pull from different columns or, what else changes?
Nick Craver
2010-02-28 13:32:58
@Nick : grid just pull from different columns.
masoud ramezani
2010-02-28 14:00:29
@masoud ramezani - Something like a GridView with autogenerate columns (see here: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.autogeneratecolumns.aspx) will do this built in, can you describe what behavior different from that you need?
Nick Craver
2010-02-28 14:11:48
@Nick : I want make a report generator for my application and give ability to my end user that generate a form that contains her/his ideals columns.
masoud ramezani
2010-02-28 14:54:56