Pgae Directive

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim Heavey

    #1

    Pgae Directive

    Is the Page directive only go on ".aspx" pages? I think the answer is yes,
    but I am not positive. I am trying to figure out why a called class can not
    be found and I was wondering if I should place a page directive on the class
    which I am trying to call.

    In my situation I have "MyPage.asp x" which has code behind page called
    "MyPage.aspx.vb " and "MyPage.aspx.vb " instatiates "Myclass.vb " and the
    "MyClass.vb " can not be found. All my code is source code, not compiled code,
    so I am using the page directive of @Page Inherits="MyPag e"
    src="MyPage.asp x.vb". When "MyPage.aspx.vb " instatiates "MyClass.vb " it fails
    with a compile error.

    I have taken the "MyClass.vb " and created a new project and compiled the code
    as a new project and placed that dll into the bin folder, but then I get an
    error of "Invalid Type" when the class is instatiated.

    I have tried using the @Assembly directive of @Assembly src="MyClass.vb ", but
    this has no effect.

    How can I resolve this error allowing the source code to be compiled on the
    fly?


  • Jerry III

    #2
    Re: Pgae Directive

    First, yes, the page directive is only good in ASPX pages. Second, you can't
    reference code behind pages from other code behind pages without compiling
    them. You either have to put all of that code in one file or you have to
    write it so it doesn't reference each other. Or you have to compile all but
    one and put the compiled code in the /bin directory.

    Jerry

    "Jim Heavey" <JimHeavey@hotm ail.com> wrote in message
    news:OLcj1sKlDH A.3320@tk2msftn gp13.phx.gbl...[color=blue]
    > Is the Page directive only go on ".aspx" pages? I think the answer is[/color]
    yes,[color=blue]
    > but I am not positive. I am trying to figure out why a called class can[/color]
    not[color=blue]
    > be found and I was wondering if I should place a page directive on the[/color]
    class[color=blue]
    > which I am trying to call.
    >
    > In my situation I have "MyPage.asp x" which has code behind page called
    > "MyPage.aspx.vb " and "MyPage.aspx.vb " instatiates "Myclass.vb " and the
    > "MyClass.vb " can not be found. All my code is source code, not compiled[/color]
    code,[color=blue]
    > so I am using the page directive of @Page Inherits="MyPag e"
    > src="MyPage.asp x.vb". When "MyPage.aspx.vb " instatiates "MyClass.vb " it[/color]
    fails[color=blue]
    > with a compile error.
    >
    > I have taken the "MyClass.vb " and created a new project and compiled the[/color]
    code[color=blue]
    > as a new project and placed that dll into the bin folder, but then I get[/color]
    an[color=blue]
    > error of "Invalid Type" when the class is instatiated.
    >
    > I have tried using the @Assembly directive of @Assembly src="MyClass.vb ",[/color]
    but[color=blue]
    > this has no effect.
    >
    > How can I resolve this error allowing the source code to be compiled on[/color]
    the[color=blue]
    > fly?
    >
    >[/color]


    Comment

    • Jim Heavey

      #3
      Re: Pgae Directive

      Then what is the purpose of the "<%@ Assembly" directive?
      That directive allows you to link together application and
      it as a "src=" option which seems to imply that you can
      have strait source rather then compiled code.

      Am I missing something?[color=blue]
      >-----Original Message-----
      >First, yes, the page directive is only good in ASPX[/color]
      pages. Second, you can't[color=blue]
      >reference code behind pages from other code behind pages[/color]
      without compiling[color=blue]
      >them. You either have to put all of that code in one file[/color]
      or you have to[color=blue]
      >write it so it doesn't reference each other. Or you have[/color]
      to compile all but[color=blue]
      >one and put the compiled code in the /bin directory.
      >
      >Jerry
      >
      >"Jim Heavey" <JimHeavey@hotm ail.com> wrote in message
      >news:OLcj1sKlD HA.3320@tk2msft ngp13.phx.gbl.. .[color=green]
      >> Is the Page directive only go on ".aspx" pages? I[/color][/color]
      think the answer is[color=blue]
      >yes,[color=green]
      >> but I am not positive. I am trying to figure out why a[/color][/color]
      called class can[color=blue]
      >not[color=green]
      >> be found and I was wondering if I should place a page[/color][/color]
      directive on the[color=blue]
      >class[color=green]
      >> which I am trying to call.
      >>
      >> In my situation I have "MyPage.asp x" which has code[/color][/color]
      behind page called[color=blue][color=green]
      >> "MyPage.aspx.vb " and "MyPage.aspx.vb "[/color][/color]
      instatiates "Myclass.vb " and the[color=blue][color=green]
      >> "MyClass.vb " can not be found. All my code is source[/color][/color]
      code, not compiled[color=blue]
      >code,[color=green]
      >> so I am using the page directive of @Page[/color][/color]
      Inherits="MyPag e"[color=blue][color=green]
      >> src="MyPage.asp x.vb". When "MyPage.aspx.vb "[/color][/color]
      instatiates "MyClass.vb " it[color=blue]
      >fails[color=green]
      >> with a compile error.
      >>
      >> I have taken the "MyClass.vb " and created a new project[/color][/color]
      and compiled the[color=blue]
      >code[color=green]
      >> as a new project and placed that dll into the bin[/color][/color]
      folder, but then I get[color=blue]
      >an[color=green]
      >> error of "Invalid Type" when the class is instatiated.
      >>
      >> I have tried using the @Assembly directive of @Assembly[/color][/color]
      src="MyClass.vb ",[color=blue]
      >but[color=green]
      >> this has no effect.
      >>
      >> How can I resolve this error allowing the source code[/color][/color]
      to be compiled on[color=blue]
      >the[color=green]
      >> fly?
      >>
      >>[/color]
      >
      >
      >.
      >[/color]

      Comment

      • Jerry III

        #4
        Re: Pgae Directive

        You're missing the fact that the assembly will only be visible in the page
        that contains the directive, but not in other assemblies you include in the
        same page. To have the assemblies see each other you have to compile them
        and use Using Assembly.Name (in C#) within the assembly files.

        Jerry

        "Jim Heavey" <anonymous@disc ussions.microso ft.com> wrote in message
        news:025101c394 ce$ef7daab0$a10 1280a@phx.gbl.. .[color=blue]
        > Then what is the purpose of the "<%@ Assembly" directive?
        > That directive allows you to link together application and
        > it as a "src=" option which seems to imply that you can
        > have strait source rather then compiled code.
        >
        > Am I missing something?[color=green]
        > >-----Original Message-----
        > >First, yes, the page directive is only good in ASPX[/color]
        > pages. Second, you can't[color=green]
        > >reference code behind pages from other code behind pages[/color]
        > without compiling[color=green]
        > >them. You either have to put all of that code in one file[/color]
        > or you have to[color=green]
        > >write it so it doesn't reference each other. Or you have[/color]
        > to compile all but[color=green]
        > >one and put the compiled code in the /bin directory.
        > >
        > >Jerry
        > >
        > >"Jim Heavey" <JimHeavey@hotm ail.com> wrote in message
        > >news:OLcj1sKlD HA.3320@tk2msft ngp13.phx.gbl.. .[color=darkred]
        > >> Is the Page directive only go on ".aspx" pages? I[/color][/color]
        > think the answer is[color=green]
        > >yes,[color=darkred]
        > >> but I am not positive. I am trying to figure out why a[/color][/color]
        > called class can[color=green]
        > >not[color=darkred]
        > >> be found and I was wondering if I should place a page[/color][/color]
        > directive on the[color=green]
        > >class[color=darkred]
        > >> which I am trying to call.
        > >>
        > >> In my situation I have "MyPage.asp x" which has code[/color][/color]
        > behind page called[color=green][color=darkred]
        > >> "MyPage.aspx.vb " and "MyPage.aspx.vb "[/color][/color]
        > instatiates "Myclass.vb " and the[color=green][color=darkred]
        > >> "MyClass.vb " can not be found. All my code is source[/color][/color]
        > code, not compiled[color=green]
        > >code,[color=darkred]
        > >> so I am using the page directive of @Page[/color][/color]
        > Inherits="MyPag e"[color=green][color=darkred]
        > >> src="MyPage.asp x.vb". When "MyPage.aspx.vb "[/color][/color]
        > instatiates "MyClass.vb " it[color=green]
        > >fails[color=darkred]
        > >> with a compile error.
        > >>
        > >> I have taken the "MyClass.vb " and created a new project[/color][/color]
        > and compiled the[color=green]
        > >code[color=darkred]
        > >> as a new project and placed that dll into the bin[/color][/color]
        > folder, but then I get[color=green]
        > >an[color=darkred]
        > >> error of "Invalid Type" when the class is instatiated.
        > >>
        > >> I have tried using the @Assembly directive of @Assembly[/color][/color]
        > src="MyClass.vb ",[color=green]
        > >but[color=darkred]
        > >> this has no effect.
        > >>
        > >> How can I resolve this error allowing the source code[/color][/color]
        > to be compiled on[color=green]
        > >the[color=darkred]
        > >> fly?
        > >>
        > >>[/color]
        > >
        > >
        > >.
        > >[/color][/color]


        Comment

        • Jalil Vaidya

          #5
          Re: Pgae Directive

          I hope I understood you question correctly. To use the class, you will
          have to Import the namespace that the class is in. If the class is in a
          DLL then you will have to add it to the references of the project.

          Jalil Vaidya

          Jim Heavey wrote:
          [color=blue]
          > Is the Page directive only go on ".aspx" pages? I think the answer is yes,
          > but I am not positive. I am trying to figure out why a called class can not
          > be found and I was wondering if I should place a page directive on the class
          > which I am trying to call.
          >
          > In my situation I have "MyPage.asp x" which has code behind page called
          > "MyPage.aspx.vb " and "MyPage.aspx.vb " instatiates "Myclass.vb " and the
          > "MyClass.vb " can not be found. All my code is source code, not compiled code,
          > so I am using the page directive of @Page Inherits="MyPag e"
          > src="MyPage.asp x.vb". When "MyPage.aspx.vb " instatiates "MyClass.vb " it fails
          > with a compile error.
          >
          > I have taken the "MyClass.vb " and created a new project and compiled the code
          > as a new project and placed that dll into the bin folder, but then I get an
          > error of "Invalid Type" when the class is instatiated.
          >
          > I have tried using the @Assembly directive of @Assembly src="MyClass.vb ", but
          > this has no effect.
          >
          > How can I resolve this error allowing the source code to be compiled on the
          > fly?
          >
          >[/color]

          Comment

          • Jalil Vaidya

            #6
            Re: Pgae Directive

            I hope I understood you question correctly. To use the class, you will
            have to Import the namespace that the class is in. If the class is in a
            DLL then you will have to add it to the references of the project.

            Jalil Vaidya

            Jim Heavey wrote:
            [color=blue]
            > Is the Page directive only go on ".aspx" pages? I think the answer is yes,
            > but I am not positive. I am trying to figure out why a called class can not
            > be found and I was wondering if I should place a page directive on the class
            > which I am trying to call.
            >
            > In my situation I have "MyPage.asp x" which has code behind page called
            > "MyPage.aspx.vb " and "MyPage.aspx.vb " instatiates "Myclass.vb " and the
            > "MyClass.vb " can not be found. All my code is source code, not compiled code,
            > so I am using the page directive of @Page Inherits="MyPag e"
            > src="MyPage.asp x.vb". When "MyPage.aspx.vb " instatiates "MyClass.vb " it fails
            > with a compile error.
            >
            > I have taken the "MyClass.vb " and created a new project and compiled the code
            > as a new project and placed that dll into the bin folder, but then I get an
            > error of "Invalid Type" when the class is instatiated.
            >
            > I have tried using the @Assembly directive of @Assembly src="MyClass.vb ", but
            > this has no effect.
            >
            > How can I resolve this error allowing the source code to be compiled on the
            > fly?
            >
            >[/color]

            Comment

            Working...