开发者

Is it possible to create a .ascx virtually? i.e. not on disk, but as a string?

开发者 https://www.devze.com 2022-12-10 20:20 出处:网络
I was wondering if开发者_如何转开发 it was possible to load a asp.net control (.ascx) that doesn\'t reside on the file system?

I was wondering if开发者_如何转开发 it was possible to load a asp.net control (.ascx) that doesn't reside on the file system?

Like say a string variable?


Not a string varible but you can load it from resources or zip file, but you have to have full trust. Google for VirtualPathProvider.

As of 4.0 you don't have to have full trust.


System.Reflection.Emit

Assembly.Load(byte[])

No designer for you if you do this though.


You could try this:

string controlString = //read or build it
Control control = this.Page.TemplateControl.ParseControl(controlString);

More information is available here:

http://msdn.microsoft.com/en-us/library/kz3ffe28.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消