Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Sep 17, 2010 @ 13:36
    Jeroen Breuer
    0

    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

  • Stig Kulvedrøsten 48 posts 69 karma points
    Sep 17, 2010 @ 14:24
  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Sep 17, 2010 @ 14:27
    Lee Kelleher
    0

    +1 Server Controls are the way to go.  Either inherit from Control or WebControl (I prefer the latter).

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Sep 17, 2010 @ 14:29
    Jeroen Breuer
    0

    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

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Sep 17, 2010 @ 14:32
    Lee Kelleher
    0

    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.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Sep 17, 2010 @ 14:40
    Jeroen Breuer
    0

    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

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 17, 2010 @ 14:41
    Aaron Powell
    0

    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

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Sep 17, 2010 @ 14:47
    Jeroen Breuer
    0

    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

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Sep 17, 2010 @ 18:42
    Jeroen Breuer
    0

    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

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 18, 2010 @ 01:14
    Aaron Powell
    0

    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.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Sep 18, 2010 @ 09:53
    Jeroen Breuer
    0

    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

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 18, 2010 @ 12:58
    Aaron Powell
    0

    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 ;))

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Sep 18, 2010 @ 14:01
    Jeroen Breuer
    0

    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

  • atze187 160 posts 215 karma points
    Sep 18, 2010 @ 14:06
    atze187
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft