Share User Control Across Applications - How?

Discussion in 'ASP .Net' started by Chad A. Beckner, Jun 7, 2004.

  1. Hey everyone,

    Ok. I have a "template and skin" setup on the beginnings of a new portal
    site. In this site, there are going to be many applications, which will be
    store underneath the "master" site. How can I share the template user
    controls with these "sub-applications"?

    Example:

    Root
    |
    | -> Per article from Microsoft's website, 825996, I have setup a
    virtual directory that points to the "common" folder, named
    "intranet_common_folder".
    | -> Secure Portal Site Folder (say, intranet)
    |
    | -> Common (a common place to put all my template controls and
    other "app-sharing controls"
    |-> Some Class or .ascx file or .asp file, etc
    | -> WebApplication1 (uses a .ascx file from Common)
    | -> WebApplication2 (uses a .ascx file from Common)

    Ideas? I've tried the virtual directory approach, but that doesn't work, I
    get "The virtual path
    '/intranet_common_folder/themes/06_01_2004/site_theme/site_template.ascx'
    maps to another application, which is not allowed.". Since I will not have
    access to the GAC, and I don't want to have our Admin have to publish to the
    GAC, how can I do this?

    Thanks for any and all help!

    Chad
     
    Chad A. Beckner, Jun 7, 2004
    #1
    1. Advertising

  2. "Chad A. Beckner" <> wrote in message
    news:...
    > Hey everyone,
    >
    > Ok. I have a "template and skin" setup on the beginnings of a new

    portal
    > site. In this site, there are going to be many applications, which will

    be
    > store underneath the "master" site. How can I share the template user
    > controls with these "sub-applications"?


    This can be tricky, as User Controls aren't really meant to work this way.
    Microsoft seems to have intended anything sophisticated like this to be done
    with Custom Controls.
    --
    John Saunders
    johnwsaundersiii at hotmail
     
    John Saunders, Jun 7, 2004
    #2
    1. Advertising

  3. Hey John (hehe, do you live on this newgroup?! hehe)...

    Anyways, do you mean, .vb class files? I have those, and those seem to be
    working. BUT, they do "reference" the site template file, which is an .ascx
    file. Do I need to digitially sign it for it to work? I don't want to put
    it into the GAC, that's not an option. Basically, I guess, can you point me
    in a direction for custom controls and those that load an .ascx (or
    whatever) from a folder that is not part of the current application?

    Thanks John!

    Chad



    "John Saunders" <> wrote in message
    news:...
    > "Chad A. Beckner" <> wrote in message
    > news:...
    > > Hey everyone,
    > >
    > > Ok. I have a "template and skin" setup on the beginnings of a new

    > portal
    > > site. In this site, there are going to be many applications, which will

    > be
    > > store underneath the "master" site. How can I share the template user
    > > controls with these "sub-applications"?

    >
    > This can be tricky, as User Controls aren't really meant to work this way.
    > Microsoft seems to have intended anything sophisticated like this to be

    done
    > with Custom Controls.
    > --
    > John Saunders
    > johnwsaundersiii at hotmail
    >
    >
     
    Chad A. Beckner, Jun 7, 2004
    #3
  4. "Chad A. Beckner" <> wrote in message
    news:%...
    > Hey John (hehe, do you live on this newgroup?! hehe)...


    No. I spend the rest of my time online looking for work...

    > Anyways, do you mean, .vb class files? I have those, and those seem to be
    > working. BUT, they do "reference" the site template file, which is an

    ..ascx
    > file. Do I need to digitially sign it for it to work?


    No, that's got nothing to do with it.

    > I don't want to put
    > it into the GAC, that's not an option. Basically, I guess, can you point

    me
    > in a direction for custom controls and those that load an .ascx (or
    > whatever) from a folder that is not part of the current application?


    The issue with user controls is that they were meant to be a simple
    mechanism for creating common content. But "simple" includes some
    restrictions. The fact that you can't easily share them between sites is one
    of those limitations.

    I'll give you some references to documentation on custom controls:

    ASP.NET Server Control Development Basics
    (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht
    ml/cpconwebformscontroldevelopmentbasics.asp)

    Developing a Composite Control
    (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht
    ml/cpcondevelopingcompositecontrols.asp)

    Before this scares you away, I'll tell you that it's fairly easy to create a
    custom control to duplicate the functionality of a user control. The
    "Composite Control" article talks about the sort of control you'll need. For
    the most part, all you'll need to do is to override the CreateChildControls
    method, instantiate and initialize each of your child controls and add them
    to the Controls collection. That way, you don't even need to worry about
    rendering the control - the child controls will do that for you:

    <%@ Control Language="vb" AutoEventWireup="false" Codebehind="uc.ascx.vb"
    Inherits="ns.uc"
    TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
    <asp:Label runat="server" Text="User:" /><asp:TextBox runat="server"
    id="txtUser"/><br>
    <asp:Label runat="server" Text="Password:"/><asp:TextBox runat="server"
    id="txtPassword"/><br>


    translates into:

    Protected Overrides Sub CreateChildControls()
    Dim lblUser As New Label()
    lblUser.Text = "User:"
    Controls.Add(lblUser)

    Dim txtUser as New TextBox()
    txtUser.Id = "txtUser"
    Controls.Add(txtUser)

    Dim lblPassword as New Label()
    lblPassword.Text = "Password:"
    Controls.Add(lblPassword)

    Dim txtPassword as New TextBox()
    txtPassword.Id = "txtPassword"
    Controls.Add(txtPassword)

    MyBase.CreateChildControls()
    End Sub

    Not a real big deal.
    --
    John Saunders
    johnwsaundersiii at hotmail
     
    John Saunders, Jun 7, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mg
    Replies:
    1
    Views:
    487
    Hermit Dave
    Dec 18, 2003
  2. Jon Paugh

    share aspx across web applications

    Jon Paugh, Jan 20, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    492
    Chris Jackson
    Jan 20, 2004
  3. Jason Barnett

    Share data across web applications?

    Jason Barnett, Jan 20, 2010, in forum: ASP .Net
    Replies:
    1
    Views:
    838
    Mr. Arnold
    Jan 21, 2010
  4. mg

    Share user control across applications

    mg, Dec 18, 2003, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    237
    James Radke
    Dec 19, 2003
  5. Saraswati lakki
    Replies:
    0
    Views:
    1,390
    Saraswati lakki
    Jan 6, 2012
Loading...

Share This Page