Re: Include Files -> UserControls

Discussion in 'ASP .Net' started by Neske, May 6, 2004.

  1. Neske

    Neske Guest

    Hi Everyone,

    I have a question. I have to make a project for school with asp.net
    I'm a newbie and i thaught everything went very well untill yesterday
    My project is based on include files and yesterday I heard we can't us
    include files but we have to use usercontrols. Do you know if there'
    an easy way to make usercontrols of these include files?

    Thanx

    nesk


    -
    Nesk
    -----------------------------------------------------------------------
    Posted via http://www.mcse.m
    -----------------------------------------------------------------------
    View this thread: http://www.mcse.ms/message645946.htm
     
    Neske, May 6, 2004
    #1
    1. Advertising

  2. Neske

    Rick Spiewak Guest

    Your contents go into an .ascx file. You can look this up in the help files,
    but here's part of it:
    User controls work only when they are included in a Web Forms page. When a
    request arrives for a page and that page contains a user control, the user
    control goes through all of the processing stages that any ASP.NET server
    control is subject to. For more information about these processing stages,
    see Web Forms Page Processing.

    Including a user control in a Web Forms page is simple.

    To include a user control in a Web Forms page

    1.. In the containing Web Forms page, declare an @ Register directive that
    includes:
    a.. A tagprefix attribute, which associates a prefix with the user
    control. This prefix will be included in opening tag of the user control
    element.
    b.. A tagname attribute, which associates a name with the user control.
    This name will be included in the opening tag of the user control element.
    c.. A Src attribute, which defines the virtual path to the user control
    file that you are including in the Web Forms page.
    Note The Src attribute value can be either a relative or an absolute
    path to the user control source file from your application's root directory.
    For ease of use, it is recommended you use a relative path. The tilde (~)
    character represents the root directory of the application.
    For example, the following code registers a user control defined in the
    file Login1.ascx. It has been given the tag prefix Acme and the tag name
    Login. The file is located in a Controls directory.

    <%@ Register TagPrefix="Acme" TagName="Login" Src="~\controls\login1.ascx"
    %>2.. Using custom server control syntax, declare the user control element
    between the opening and closing tags of the HtmlForm server control (<form
    runat=server></form>). For example, to declare the control imported in the
    previous step, use the following syntax.
    <html>
    <body>
    <form runat="server">
    <Acme:Login id="MyLogin" runat="server"/>
    </form>
    </body>
    </html>Note Regardless of how many ASP.NET server controls (user controls
    and any others) you include on your Web Forms page, you should include only
    one HtmlForm server control on a Web Forms page. Include all server controls
    between the opening and closing tags of this control.
    "Neske" <> wrote in message
    news:...
    >
    > Hi Everyone,
    >
    > I have a question. I have to make a project for school with asp.net.
    > I'm a newbie and i thaught everything went very well untill yesterday.
    > My project is based on include files and yesterday I heard we can't use
    > include files but we have to use usercontrols. Do you know if there's
    > an easy way to make usercontrols of these include files?
    >
    > Thanx
    >
    > neske
    >
    >
    >
    > --
    > Neske
    > ------------------------------------------------------------------------
    > Posted via http://www.mcse.ms
    > ------------------------------------------------------------------------
    > View this thread: http://www.mcse.ms/message645946.html
    >
     
    Rick Spiewak, May 7, 2004
    #2
    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. Danny Anderson
    Replies:
    5
    Views:
    531
    Victor Bazarov
    Aug 15, 2003
  2. Rolf Magnus
    Replies:
    2
    Views:
    630
    Karl Heinz Buchegger
    Nov 28, 2003
  3. Elie Nader
    Replies:
    1
    Views:
    666
  4. Andreas Bogenberger
    Replies:
    3
    Views:
    1,014
    Andreas Bogenberger
    Feb 22, 2008
  5. JJA
    Replies:
    13
    Views:
    333
    John Saunders
    Jul 27, 2004
Loading...

Share This Page