SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru siphilp's Avatar
    Join Date
    Nov 2001
    Location
    Fife, Scotland
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Microsoft .Net Files

    Hi there,
    Does anyone know the right way to declare an include file in an aspx page?


    Cheers


    Si

  2. #2
    SitePoint Addict
    Join Date
    Jun 2001
    Location
    Newcastle, England
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There isn't one . Classic ASP includes have no place in .NET, it's a totally different architecture and there are totally different ways of doing things .
    Nick Wilson [ - email - ]

  3. #3
    SitePoint Guru siphilp's Avatar
    Join Date
    Nov 2001
    Location
    Fife, Scotland
    Posts
    663
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Sorry more to this that meets the eye

    Hi there again,
    In .Net the classic <!-- #include virtual="Blah"--> works. Here is the problem. Take the default page

    ____Default.asp________
    #include topmenu.asp(% javascript sources)
    #include leftmenu.asp (Html, Javascript)
    then there is the content.

    All this works without .net as that is how it is set up now. When you try to do the same in .Net IIS doesn't know/understand what to do with topmenu.asp cos it contains links to the javascript source file (.js).
    Anyone have any ideas?

    If the above doesn't make sense or need more info please contact me.


    Si

  4. #4
    SitePoint Enthusiast pedershk's Avatar
    Join Date
    Mar 2001
    Location
    Oslo, Norway
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to create your "include files" as Server Controls.

    Then you reference them like so (in your "main" file)

    Code:
    <%@ Register TagPrefix="YOURTAGPREFIX" TagName="YOURTAGNAME" src="filename.ascx">
    
      <html><body>
        blahblahblah....
         <form runat=server>
           <YOURTAGPREFIX:YOURTAGNAME id="Control1" runat="server" 
             property1="blah" property2="blahblah" />
         </form>
        blahblahblah
      </body></html>
    The tag prefix would be your "namespace", for example your company name, "MyTags", etc. Both that attribute and tagname is up to you. The src, ofcourse, references the actual "include file". Note that the default extension for a user control is .ascx. Not sure if this is strictly enforced or not. If you use VS.NET, this is the default.

    Ofcourse, your actual "include file", or user control, shouldn't contain any <html></html> statements, since that would mess up the page flow. Also, please note that you can include properties that are sent back to the custom control, like arguments to functions.

    I got all this from "Sams Teach Yourself ASP.NET in 21 Days".
    **Henning K. Pedersen**
    Forbrukerkraft Norway A/S

  5. #5
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is the Sams book any good? I been considering getting a book on ASP.NET, as I've done most of the tutorials at getdotnet ()



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •