I'm building a package in which I'm using a usercontrol. I want to embed this usercontrol inside the dll (just like uComponents embeds all the javascript and css files), but I don't know how. Can anybody help me with this? Thanks.
I tried publishing my entire project in VS2010, but the published folder still contains the .ascx file. Anybody know how I can publish my webappliction in VS2010 without the .ascx because it should be in the dl.
At TheFARM we had a project which has ASCX files compiled as resources of the assembly, but really it's a hell of a lot more effort than it's worth though, the only reason I'd go with it is to completely lock down the ability for people to modify the markup of your ASCX, but really, who'd do that :P
Thanks for the tip Slace. I looked at the source code of uComponents and I saw it has js and css files embedded inside the dll. I thought it would be just as easy to do the same with a usercontrol, but if it's a lot harder I might just keep the usercontrol loose and not embed it into the dll.
Well I decided to use a custom control (the DataEditor of the custom datatype) instead of a user control. Because of this all my custom datatype code can be in a single dll (just like uComponents), but I also want to use the openmodal popup inside my custom datatype. If I want to use the openmodal I need to point to a page. How can I do this without using a real page (because I can't embed those inside the dll either)? Am I forced to use pages for this (so I can't store everything inside the dll) or is there a better solution?
Thanks Slace. Guess I'll be forced to use something the openmodal can point to. Could also be a .ashx file for instance since I want to code everything in the code behind file. I once heard of pointing to a .dll file with a querystring and it would return html. Never tried that before but could it be possible I embed everything into my dll and let the openmodal point to the dll with a querystring so it returns html? Seems like a nice experiment :).
Yeah you can use a HttpHandler, as the request to that will run the whole life cycle, you can't perform a request to an ASCX file (well, not easily ;))
Sounds good but how can I point to a HttpHandler in the openmodal javascript? It needs a url where the HttpHandler is, but it's compiled in the dll. This is al pretty new to me :).
Embed usercontrol inside a dll
Hello,
I'm building a package in which I'm using a usercontrol. I want to embed this usercontrol inside the dll (just like uComponents embeds all the javascript and css files), but I don't know how. Can anybody help me with this? Thanks.
Jeroen
http://www.beansoftware.com/ASP.NET-Tutorials/Custom-Server-Controls.aspx
and
http://msdn.microsoft.com/en-us/library/bb398930.aspx
is a good start, and then google :)
+1 Server Controls are the way to go. Either inherit from Control or WebControl (I prefer the latter).
Thanks for the tips, but I prefer a usercontrol since I think it's easier to maintain the html in instead of a custom control. For now I'm trying this: http://www.nathanblevins.com/Articles/Compile-a-Web-User-Control-into-a-DLL-.Net-c-.aspx.
Jeroen
Bah, half the fun is getting into a complete spaghetti mess with the HtmlTextWriter! ;-) haha
Best of luck with your control. Let us know how you get on - interested to know how it works out.
Cheers, Lee.
I tried publishing my entire project in VS2010, but the published folder still contains the .ascx file. Anybody know how I can publish my webappliction in VS2010 without the .ascx because it should be in the dl.
Jeroen
You can use the virtual path utility to do some funky stuff, and what you're trying to achieve should also be doable: http://msdn.microsoft.com/en-us/library/system.web.virtualpathutility.aspx
At TheFARM we had a project which has ASCX files compiled as resources of the assembly, but really it's a hell of a lot more effort than it's worth though, the only reason I'd go with it is to completely lock down the ability for people to modify the markup of your ASCX, but really, who'd do that :P
Thanks for the tip Slace. I looked at the source code of uComponents and I saw it has js and css files embedded inside the dll. I thought it would be just as easy to do the same with a usercontrol, but if it's a lot harder I might just keep the usercontrol loose and not embed it into the dll.
Jeroen
Well I decided to use a custom control (the DataEditor of the custom datatype) instead of a user control. Because of this all my custom datatype code can be in a single dll (just like uComponents), but I also want to use the openmodal popup inside my custom datatype. If I want to use the openmodal I need to point to a page. How can I do this without using a real page (because I can't embed those inside the dll either)? Am I forced to use pages for this (so I can't store everything inside the dll) or is there a better solution?
Jeroen
There's a real difference between CSS and JavaScript than there is for an ASCX, because of how they are required for the request process.
And if openmodal requires a page then you'll have to create a page, there wont be a way around it.
Thanks Slace. Guess I'll be forced to use something the openmodal can point to. Could also be a .ashx file for instance since I want to code everything in the code behind file. I once heard of pointing to a .dll file with a querystring and it would return html. Never tried that before but could it be possible I embed everything into my dll and let the openmodal point to the dll with a querystring so it returns html? Seems like a nice experiment :).
Jeroen
Yeah you can use a HttpHandler, as the request to that will run the whole life cycle, you can't perform a request to an ASCX file (well, not easily ;))
Sounds good but how can I point to a HttpHandler in the openmodal javascript? It needs a url where the HttpHandler is, but it's compiled in the dll. This is al pretty new to me :).
Jeroen
Hi Jeroen,
you'll need to register that handler (http://msdn.microsoft.com/en-us/library/46c5ddfy.aspx) and then point openmodal to the uri you configured in web.config.
atze
is working on a reply...