views:

50

answers:

1

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") %>'

+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
I want to give this ability to user that make a returned data form as a grid.
masoud ramezani
@masoud ramezani - Does the grid just pull from different columns or, what else changes?
Nick Craver
@Nick : grid just pull from different columns.
masoud ramezani
@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
@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