WebAppication project doesn't like separate codefiles

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • cmrchs@gmail.com

    WebAppication project doesn't like separate codefiles

    Hi,

    I have in my web application project (VS.NET 2008) :
    - a webform (webform2.aspx, webform2.aspx.c s,
    webform2.aspx.d esigner.cs)
    - a code-file Product.cs.

    But i can't use the definition of 'Product' nowhere in my page-class-
    file (webform2.aspx. cs)

    For example:

    protected void Page_Load(objec t sender, EventArgs e)
    {
    Product p = new Product();
    }

    the compiler doesn't know the definition of Product

    whereas if I place the definition of Product in the same codefile as
    the WebForm.cs then it works.

    How can i make it work just by keeping each class definition in its
    own codefile?
    By the way, what happened to the App_Code used in 2005?

    thank you
    Chris
  • Anthony Jones

    #2
    Re: WebAppication project doesn't like separate codefiles

    <cmrchs@gmail.c omwrote in message
    news:399ab0fe-8b10-4b04-a40a-5534d6a90432@a1 g2000hsb.google groups.com...
    Hi,
    >
    I have in my web application project (VS.NET 2008) :
    - a webform (webform2.aspx, webform2.aspx.c s,
    webform2.aspx.d esigner.cs)
    - a code-file Product.cs.
    >
    But i can't use the definition of 'Product' nowhere in my page-class-
    file (webform2.aspx. cs)
    >
    For example:
    >
    protected void Page_Load(objec t sender, EventArgs e)
    {
    Product p = new Product();
    }
    >
    the compiler doesn't know the definition of Product
    >
    whereas if I place the definition of Product in the same codefile as
    the WebForm.cs then it works.
    >
    How can i make it work just by keeping each class definition in its
    own codefile?
    By the way, what happened to the App_Code used in 2005?
    >
    If App_Code isn't there its because it hasn't been created yet. App_Code is
    where your Product.cs should be. I would recommend you use a namespace as
    well the word 'Product' is fairly common.


    --
    Anthony Jones - MVP ASP/ASP.NET


    Comment

    • Cowboy \(Gregory A. Beamer\)

      #3
      Re: WebAppication project doesn't like separate codefiles

      I concur with App_Code, if not in its own assembly. If that is not to your
      liking, make sure you have the proper namespace referenced in your code
      behind/beside file.

      --
      Gregory A. Beamer
      MVP, MCP: +I, SE, SD, DBA

      Subscribe to my blog


      or just read it:


      *************** *************** **************
      | Think outside the box! |
      *************** *************** **************
      <cmrchs@gmail.c omwrote in message
      news:399ab0fe-8b10-4b04-a40a-5534d6a90432@a1 g2000hsb.google groups.com...
      Hi,
      >
      I have in my web application project (VS.NET 2008) :
      - a webform (webform2.aspx, webform2.aspx.c s,
      webform2.aspx.d esigner.cs)
      - a code-file Product.cs.
      >
      But i can't use the definition of 'Product' nowhere in my page-class-
      file (webform2.aspx. cs)
      >
      For example:
      >
      protected void Page_Load(objec t sender, EventArgs e)
      {
      Product p = new Product();
      }
      >
      the compiler doesn't know the definition of Product
      >
      whereas if I place the definition of Product in the same codefile as
      the WebForm.cs then it works.
      >
      How can i make it work just by keeping each class definition in its
      own codefile?
      By the way, what happened to the App_Code used in 2005?
      >
      thank you
      Chris

      Comment

      • cmrchs@gmail.com

        #4
        Re: WebAppication project doesn't like separate codefiles

        On Aug 1, 7:39 pm, "Cowboy \(Gregory A. Beamer\)"
        <NoSpamMgbwo... @comcast.netNoS pamMwrote:
        I concur with App_Code, if not in its own assembly. If that is not to your
        liking, make sure you have the proper namespace referenced in your code
        behind/beside file.
        >
        --
        Gregory A. Beamer
        MVP, MCP: +I, SE, SD, DBA
        >
        Subscribe to my bloghttp://gregorybeamer.s paces.live.com/lists/feed.rss
        >
        or just read it:http://gregorybeamer.spaces.live.com/
        >
        *************** *************** **************
        | Think outside the box! |
        *************** *************** **************< cmr...@gmail.co mwrote in message
        >
        news:399ab0fe-8b10-4b04-a40a-5534d6a90432@a1 g2000hsb.google groups.com...
        >
        Hi,
        >
        I have in my web application project (VS.NET 2008) :
        - a webform (webform2.aspx, webform2.aspx.c s,
        webform2.aspx.d esigner.cs)
        - a code-file Product.cs.
        >
        But i can't use the definition of 'Product' nowhere in my page-class-
        file (webform2.aspx. cs)
        >
        For example:
        >
        protected void Page_Load(objec t sender, EventArgs e)
        {
        Product p = new Product();
        }
        >
        the compiler doesn't know the definition of Product
        >
        whereas if I place the definition of Product in the same codefile as
        the WebForm.cs then it works.
        >
        How can i make it work just by keeping each class definition in its
        own codefile?
        By the way, what happened to the App_Code used in 2005?
        >
        thank you
        Chris
        hello,

        actually I previously put the code in App_Code, but even then it
        doesn't work !
        Only when I use it inline it works, but not when placed in the code-
        behind file ???

        So, the following works:
        <script runat="server">
        void Button1_Click(o bject sender, EventArgs e)
        {
        Product c = new Product();
        Label1.Text = c.GetMyMessage( TextBox1.Text);
        }
        </script>

        but not in the code-behind file, how come?

        why doesn't it work the 'normal' way, I mean with the code-files in
        the same directory as the aspx-file (it works like that in WinForms)
        Or is there a way?

        thank you

        Comment

        • Juan T. Llibre

          #5
          Re: WebAppication project doesn't like separate codefiles

          Do you have a line like this, to import the code-behaind class ?

          <%@ Page Language="C#" AutoEventWireup ="false" CodeFile="some. aspx.cs" Inherits="_some " %>




          Juan T. Llibre, asp.net MVP
          asp.net faq : http://asp.net.do/faq/
          foros de asp.net, en español : http://asp.net.do/foros/
          =============== =============== ========

          <cmrchs@gmail.c omwrote in message news:7c8e5c4d-955a-4542-8ac3-af23e01b3b10@a7 0g2000hsh.googl egroups.com...
          On Aug 1, 7:39 pm, "Cowboy \(Gregory A. Beamer\)"
          <NoSpamMgbwo... @comcast.netNoS pamMwrote:
          >I concur with App_Code, if not in its own assembly. If that is not to your
          >liking, make sure you have the proper namespace referenced in your code
          >behind/beside file.
          >>
          >--
          >Gregory A. Beamer
          >MVP, MCP: +I, SE, SD, DBA
          >>
          >Subscribe to my bloghttp://gregorybeamer.s paces.live.com/lists/feed.rss
          >>
          >or just read it:http://gregorybeamer.spaces.live.com/
          >>
          >************** *************** ***************
          >| Think outside the box! |
          >************** *************** *************** <cmr...@gmail.c omwrote in message
          >>
          >news:399ab0f e-8b10-4b04-a40a-5534d6a90432@a1 g2000hsb.google groups.com...
          >>
          Hi,
          >>
          I have in my web application project (VS.NET 2008) :
          - a webform (webform2.aspx, webform2.aspx.c s,
          webform2.aspx.d esigner.cs)
          - a code-file Product.cs.
          >>
          But i can't use the definition of 'Product' nowhere in my page-class-
          file (webform2.aspx. cs)
          >>
          For example:
          >>
          protected void Page_Load(objec t sender, EventArgs e)
          {
          Product p = new Product();
          }
          >>
          the compiler doesn't know the definition of Product
          >>
          whereas if I place the definition of Product in the same codefile as
          the WebForm.cs then it works.
          >>
          How can i make it work just by keeping each class definition in its
          own codefile?
          By the way, what happened to the App_Code used in 2005?
          >>
          thank you
          Chris
          >
          hello,
          >
          actually I previously put the code in App_Code, but even then it
          doesn't work !
          Only when I use it inline it works, but not when placed in the code-
          behind file ???
          >
          So, the following works:
          <script runat="server">
          void Button1_Click(o bject sender, EventArgs e)
          {
          Product c = new Product();
          Label1.Text = c.GetMyMessage( TextBox1.Text);
          }
          </script>
          >
          but not in the code-behind file, how come?
          >
          why doesn't it work the 'normal' way, I mean with the code-files in
          the same directory as the aspx-file (it works like that in WinForms)
          Or is there a way?
          >
          thank you


          Comment

          • cmrchs@gmail.com

            #6
            Re: WebAppication project doesn't like separate codefiles

            On Aug 1, 8:40 pm, "Juan T. Llibre" <nomailrepl...@ nowhere.comwrot e:
            Do you have a line like this, to import the code-behaind class ?
            >
            <%@ Page Language="C#" AutoEventWireup ="false" CodeFile="some. aspx.cs" Inherits="_some " %>
            >
            Juan T. Llibre, asp.net MVP
            asp.net faq :http://asp.net.do/faq/
            foros de asp.net, en español :http://asp.net.do/foros/
            =============== =============== ========
            >
            <cmr...@gmail.c omwrote in messagenews:7c8 e5c4d-955a-4542-8ac3-af23e01b3b10@a7 0g2000hsh.googl egroups.com...
            On Aug 1, 7:39 pm, "Cowboy \(Gregory A. Beamer\)"
            <NoSpamMgbwo... @comcast.netNoS pamMwrote:
            I concur with App_Code, if not in its own assembly. If that is not to your
            liking, make sure you have the proper namespace referenced in your code
            behind/beside file.
            >
            --
            Gregory A. Beamer
            MVP, MCP: +I, SE, SD, DBA
            >
            Subscribe to my bloghttp://gregorybeamer.s paces.live.com/lists/feed.rss
            >>
            *************** *************** **************
            | Think outside the box! |
            *************** *************** **************< cmr...@gmail.co mwrote in message
            >
            >news:399ab0f e-8b10-4b04-a40a-5534d6a90432@a1 g2000hsb.google groups.com....
            >
            Hi,
            >
            I have in my web application project (VS.NET 2008) :
            - a webform (webform2.aspx, webform2.aspx.c s,
            webform2.aspx.d esigner.cs)
            - a code-file Product.cs.
            >
            But i can't use the definition of 'Product' nowhere in my page-class-
            file (webform2.aspx. cs)
            >
            For example:
            >
            protected void Page_Load(objec t sender, EventArgs e)
            {
            Product p = new Product();
            }
            >
            the compiler doesn't know the definition of Product
            >
            whereas if I place the definition of Product in the same codefile as
            the WebForm.cs then it works.
            >
            How can i make it work just by keeping each class definition in its
            own codefile?
            By the way, what happened to the App_Code used in 2005?
            >
            thank you
            Chris
            >
            hello,
            >
            actually I previously put the code in App_Code, but even then it
            doesn't work !
            Only when I use it inline it works, but not when placed in the code-
            behind file ???
            >
            So, the following works:
            <script runat="server">
            void Button1_Click(o bject sender, EventArgs e)
            {
            Product c = new Product();
            Label1.Text = c.GetMyMessage( TextBox1.Text);
            }
            </script>
            >
            but not in the code-behind file, how come?
            >
            why doesn't it work the 'normal' way, I mean with the code-files in
            the same directory as the aspx-file (it works like that in WinForms)
            Or is there a way?
            >
            thank you
            hello,

            yes i do ... in the webApp-directory I have a file
            BindingToDataAc cessLayer.aspx starting with
            <%@ Page Language="C#" AutoEventWireup ="true"
            CodeBehind="Bin dingToDataAcces sLayer.aspx.cs"
            Inherits="WebFo rm1" %>

            in BindingToDataAc cessLayer.aspx. cs I have:

            using Products; // --COMPILER ERROR: namespace name could not
            be found
            public partial class WebForm1 : System.Web.UI.P age
            {
            protected void Page_Load(objec t sender, EventArgs e)
            {
            Product p = new Product(); // --COMPILER ERROR
            }
            }


            for the rest of my project structure:

            In App_Code i have Product.cs

            namespace Products
            {
            public class Product
            { ...}
            }

            it just doesn't make sense to me
            any suggestions?

            Chris

            Comment

            • Juan T. Llibre

              #7
              Re: WebAppication project doesn't like separate codefiles

              re:
              !in the webApp-directory I have a file BindingToDataAc cessLayer.aspx starting with:

              <%@ Page Language="C#" AutoEventWireup ="true" CodeBehind="... " Inherits="WebFo rm1" %>

              Please recheck that the Class in "BindingToDataA ccessLayer.aspx .cs" is actually named "WebForm1".

              VS 2008 follows this type of class naming syntax in code-behind files:

              In default.aspx.cs , the code-behind page for Default.aspx...
              public partial class _Default : System.Web.UI.P age

              Notice the underscore, and notice that the page's class
              is named for the page name, with an underscore added.

              It looks to me like like renamed an aspx page, but did not change the class name in the code-behind.

              The IDE does not automatically change the class name for you if you rename a file.
              If you ask me, I think it should... :-)

              In any case, for a page named "BindingToDataA ccessLayer.aspx .cs",
              this is the default syntax the IDE uses when creating the page and its code-behind class:

              <%@ Page Language="C#" AutoEventWireup ="true" CodeBehind="Bin dingToDataAcces sLayer.aspx.cs"
              Inherits="_Bind ingToDataAccess Layer" %>

              Your class can be named anything you want to,
              but the Inherits statement must point to the correct class name.




              Juan T. Llibre, asp.net MVP
              asp.net faq : http://asp.net.do/faq/
              foros de asp.net, en español : http://asp.net.do/foros/
              =============== =============== ========
              <cmrchs@gmail.c omwrote in message news:6b0f6f91-3fb2-4aad-8931-f76e86a5f8fc@8g 2000hse.googleg roups.com...
              On Aug 1, 8:40 pm, "Juan T. Llibre" <nomailrepl...@ nowhere.comwrot e:
              Do you have a line like this, to import the code-behaind class ?
              >
              <%@ Page Language="C#" AutoEventWireup ="false" CodeFile="some. aspx.cs" Inherits="_some " %>
              >
              Juan T. Llibre, asp.net MVP
              asp.net faq :http://asp.net.do/faq/
              foros de asp.net, en español :http://asp.net.do/foros/
              =============== =============== ========
              >
              <cmr...@gmail.c omwrote in messagenews:7c8 e5c4d-955a-4542-8ac3-af23e01b3b10@a7 0g2000hsh.googl egroups.com...
              On Aug 1, 7:39 pm, "Cowboy \(Gregory A. Beamer\)"
              <NoSpamMgbwo... @comcast.netNoS pamMwrote:
              I concur with App_Code, if not in its own assembly. If that is not to your
              liking, make sure you have the proper namespace referenced in your code
              behind/beside file.
              >
              --
              Gregory A. Beamer
              MVP, MCP: +I, SE, SD, DBA
              >
              Subscribe to my bloghttp://gregorybeamer.s paces.live.com/lists/feed.rss
              >>
              *************** *************** **************
              | Think outside the box! |
              *************** *************** **************< cmr...@gmail.co mwrote in message
              >
              >news:399ab0f e-8b10-4b04-a40a-5534d6a90432@a1 g2000hsb.google groups.com...
              >
              Hi,
              >
              I have in my web application project (VS.NET 2008) :
              - a webform (webform2.aspx, webform2.aspx.c s,
              webform2.aspx.d esigner.cs)
              - a code-file Product.cs.
              >
              But i can't use the definition of 'Product' nowhere in my page-class-
              file (webform2.aspx. cs)
              >
              For example:
              >
              protected void Page_Load(objec t sender, EventArgs e)
              {
              Product p = new Product();
              }
              >
              the compiler doesn't know the definition of Product
              >
              whereas if I place the definition of Product in the same codefile as
              the WebForm.cs then it works.
              >
              How can i make it work just by keeping each class definition in its
              own codefile?
              By the way, what happened to the App_Code used in 2005?
              >
              thank you
              Chris
              >
              hello,
              >
              actually I previously put the code in App_Code, but even then it
              doesn't work !
              Only when I use it inline it works, but not when placed in the code-
              behind file ???
              >
              So, the following works:
              <script runat="server">
              void Button1_Click(o bject sender, EventArgs e)
              {
              Product c = new Product();
              Label1.Text = c.GetMyMessage( TextBox1.Text);
              }
              </script>
              >
              but not in the code-behind file, how come?
              >
              why doesn't it work the 'normal' way, I mean with the code-files in
              the same directory as the aspx-file (it works like that in WinForms)
              Or is there a way?
              >
              thank you
              hello,

              yes i do ... in the webApp-directory I have a file
              BindingToDataAc cessLayer.aspx starting with
              <%@ Page Language="C#" AutoEventWireup ="true"
              CodeBehind="Bin dingToDataAcces sLayer.aspx.cs"
              Inherits="WebFo rm1" %>

              in BindingToDataAc cessLayer.aspx. cs I have:

              using Products; // --COMPILER ERROR: namespace name could not
              be found
              public partial class WebForm1 : System.Web.UI.P age
              {
              protected void Page_Load(objec t sender, EventArgs e)
              {
              Product p = new Product(); // --COMPILER ERROR
              }
              }


              for the rest of my project structure:

              In App_Code i have Product.cs

              namespace Products
              {
              public class Product
              { ...}
              }

              it just doesn't make sense to me
              any suggestions?

              Chris



              Comment

              • Mark Rae [MVP]

                #8
                Re: WebAppication project doesn't like separate codefiles

                "Juan T. Llibre" <nomailreplies@ nowhere.comwrot e in message
                news:eutHlwI9IH A.4140@TK2MSFTN GP02.phx.gbl...
                VS 2008 follows this type of class naming syntax in code-behind files:
                >
                In default.aspx.cs , the code-behind page for Default.aspx...
                public partial class _Default : System.Web.UI.P age
                >
                Notice the underscore, and notice that the page's class
                is named for the page name, with an underscore added.
                Also, the upper-case "D", C# being case-sensitive...
                It looks to me like like renamed an aspx page, but did not change the
                class name in the code-behind.
                Indeed. I've been caught out with that on more than one occasion... :-)
                The IDE does not automatically change the class name for you if you rename
                a file.
                If you ask me, I think it should... :-)
                I agree or, at the very least, pop a warning to say that there is now a
                "mismatch" (for want of a better term) between the class name specified in
                the page's @Page directive and the actual partial class specified in its
                associated code-behind file...


                --
                Mark Rae
                ASP.NET MVP


                Comment

                • cmrchs@gmail.com

                  #9
                  Re: WebAppication project doesn't like separate codefiles

                  On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
                  "Juan T. Llibre" <nomailrepl...@ nowhere.comwrot e in messagenews:eut HlwI9IHA.4140@T K2MSFTNGP02.phx .gbl...
                  >
                  VS 2008 follows this type of class naming syntax in code-behind files:
                  >
                  In default.aspx.cs , the code-behind page for Default.aspx...
                  public partial class _Default : System.Web.UI.P age
                  >
                  Notice the underscore, and notice that the page's class
                  is named for the page name, with an underscore added.
                  >
                  Also, the upper-case "D", C# being case-sensitive...
                  >
                  It looks to me like like renamed an aspx page, but did not change the
                  class name in the code-behind.
                  >
                  Indeed. I've been caught out with that on more than one occasion... :-)
                  >
                  The IDE does not automatically change the class name for you if you rename
                  a file.
                  If you ask me, I think it should... :-)
                  >
                  I agree or, at the very least, pop a warning to say that there is now a
                  "mismatch" (for want of a better term) between the class name specified in
                  the page's @Page directive and the actual partial class specified in its
                  associated code-behind file...
                  >
                  --
                  Mark Rae
                  ASP.NET MVPhttp://www.markrae.net
                  the class has the same name as specified by inherits

                  in BindingToDataAc cessLayer.aspx I have:

                  <%@ Page Language="C#" AutoEventWireup ="true"
                  CodeBehind="Bin dingToDataAcces sLayer.aspx.cs"
                  Inherits="WebFo rm1" %>

                  and in BindingToDataAc cessLayer.aspx. cs I have:

                  public partial class WebForm1 : System.Web.UI.P age
                  { }

                  if the 2 didn't match, suppose I define WebForm2 in the code behind
                  file but leave Inherits="WebFo rm1", I'd get an error in the browser
                  anyway when starting up
                  --'WebForm1' is not allowed here because it does not extend
                  class 'System.Web.UI. Page'.

                  I'm running out of options :-((

                  any suggestions?

                  Chris

                  Comment

                  • daveh551

                    #10
                    Re: WebAppication project doesn't like separate codefiles

                    On Aug 2, 7:14 am, cmr...@gmail.co m wrote:
                    On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
                    >
                    >
                    >
                    "Juan T. Llibre" <nomailrepl...@ nowhere.comwrot e in messagenews:eut HlwI9IHA.4140@T K2MSFTNGP02.phx .gbl...
                    >
                    VS 2008 follows this type of class naming syntax in code-behind files:
                    >
                    In default.aspx.cs , the code-behind page for Default.aspx...
                    public partial class _Default : System.Web.UI.P age
                    >
                    Notice the underscore, and notice that the page's class
                    is named for the page name, with an underscore added.
                    >
                    Also, the upper-case "D", C# being case-sensitive...
                    >
                    It looks to me like like renamed an aspx page, but did not change the
                    class name in the code-behind.
                    >
                    Indeed. I've been caught out with that on more than one occasion... :-)
                    >
                    The IDE does not automatically change the class name for you if you rename
                    a file.
                    If you ask me, I think it should... :-)
                    >
                    I agree or, at the very least, pop a warning to say that there is now a
                    "mismatch" (for want of a better term) between the class name specified in
                    the page's @Page directive and the actual partial class specified in its
                    associated code-behind file...
                    >
                    --
                    Mark Rae
                    ASP.NET MVPhttp://www.markrae.net
                    >
                    the class has the same name as specified by inherits
                    >
                    in BindingToDataAc cessLayer.aspx I have:
                    >
                    <%@ Page Language="C#" AutoEventWireup ="true"
                    CodeBehind="Bin dingToDataAcces sLayer.aspx.cs"
                    Inherits="WebFo rm1" %>
                    >
                    and in BindingToDataAc cessLayer.aspx. cs I have:
                    >
                    public partial class WebForm1 : System.Web.UI.P age
                    { }
                    >
                    if the 2 didn't match, suppose I define WebForm2 in the code behind
                    file but leave Inherits="WebFo rm1", I'd get an error in the browser
                    anyway when starting up
                    --'WebForm1' is not allowed here because it does not extend
                    class 'System.Web.UI. Page'.
                    >
                    I'm running out of options :-((
                    >
                    any suggestions?
                    >
                    Chris
                    Okay, this may be a totally useless suggestion, especially since
                    you're using in VS 2008, and my experience is with VS 2005, but...
                    Are you sure the product class is being compiled?
                    When I did a WebApplication in VS2005, and put classes in App_Code, I
                    had a problem where I simply could not see them in the rest of the
                    program. Even if I moved them to the root, I still couldn't see them.
                    I finally introduced deliberate syntax errors into the class, and then
                    did a Build, and the errors were not caught, thus convincing myself
                    that the files were not being included in the build.

                    I think the problem turned out to be (again, this may not apply to VS
                    2008) if you click a .cs file in the Solution explorer and look at the
                    Properties page for it, the first line there is "Build Action". For
                    the files I created in App_Code, it was set to "Content" instead of
                    "Compile", and it remained that way even if I moved the file.

                    Hope I didn't waste your time, but it might be worth looking at.

                    Comment

                    • Juan T. Llibre

                      #11
                      Re: WebAppication project doesn't like separate codefiles

                      What happens if you fully qualify the class name :

                      Inherits="YourN amespace.WebFor m1"

                      ?

                      i.e., if your namespace is named WebApp :

                      Inherits="WebAp p.WebForm1"

                      This should do it IF you are using a namespace in your codebehind...wh ich you should, anyway :

                      namespace WebApp
                      {
                      public partial class WebForm1 : System.Web.UI.P age






                      Juan T. Llibre, asp.net MVP
                      asp.net faq : http://asp.net.do/faq/
                      foros de asp.net, en español : http://asp.net.do/foros/
                      =============== =============== ========

                      <cmrchs@gmail.c omwrote in message news:96326162-186d-43b0-951c-30186b0ec02a@m7 3g2000hsh.googl egroups.com...
                      On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
                      >"Juan T. Llibre" <nomailrepl...@ nowhere.comwrot e in messagenews:eut HlwI9IHA.4140@T K2MSFTNGP02.phx .gbl...
                      >>
                      VS 2008 follows this type of class naming syntax in code-behind files:
                      >>
                      In default.aspx.cs , the code-behind page for Default.aspx...
                      public partial class _Default : System.Web.UI.P age
                      >>
                      Notice the underscore, and notice that the page's class
                      is named for the page name, with an underscore added.
                      >>
                      >Also, the upper-case "D", C# being case-sensitive...
                      >>
                      It looks to me like like renamed an aspx page, but did not change the
                      class name in the code-behind.
                      >>
                      >Indeed. I've been caught out with that on more than one occasion... :-)
                      >>
                      The IDE does not automatically change the class name for you if you rename
                      a file.
                      If you ask me, I think it should... :-)
                      >>
                      >I agree or, at the very least, pop a warning to say that there is now a
                      >"mismatch" (for want of a better term) between the class name specified in
                      >the page's @Page directive and the actual partial class specified in its
                      >associated code-behind file...
                      >>
                      >--
                      >Mark Rae
                      >ASP.NET MVP
                      http://www.markrae.net
                      >
                      the class has the same name as specified by inherits
                      >
                      in BindingToDataAc cessLayer.aspx I have:
                      >
                      <%@ Page Language="C#" AutoEventWireup ="true"
                      CodeBehind="Bin dingToDataAcces sLayer.aspx.cs"
                      Inherits="WebFo rm1" %>
                      >
                      and in BindingToDataAc cessLayer.aspx. cs I have:
                      >
                      public partial class WebForm1 : System.Web.UI.P age
                      { }
                      >
                      if the 2 didn't match, suppose I define WebForm2 in the code behind
                      file but leave Inherits="WebFo rm1", I'd get an error in the browser
                      anyway when starting up
                      --'WebForm1' is not allowed here because it does not extend
                      class 'System.Web.UI. Page'.
                      >
                      I'm running out of options :-((
                      >
                      any suggestions?
                      >
                      Chris



                      Comment

                      • cmrchs@gmail.com

                        #12
                        Re: WebAppication project doesn't like separate codefiles

                        On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
                        "Juan T. Llibre" <nomailrepl...@ nowhere.comwrot e in messagenews:eut HlwI9IHA.4140@T K2MSFTNGP02.phx .gbl...
                        >
                        VS 2008 follows this type of class naming syntax in code-behind files:
                        >
                        In default.aspx.cs , the code-behind page for Default.aspx...
                        public partial class _Default : System.Web.UI.P age
                        >
                        Notice the underscore, and notice that the page's class
                        is named for the page name, with an underscore added.
                        >
                        Also, the upper-case "D", C# being case-sensitive...
                        >
                        It looks to me like like renamed an aspx page, but did not change the
                        class name in the code-behind.
                        >
                        Indeed. I've been caught out with that on more than one occasion... :-)
                        >
                        The IDE does not automatically change the class name for you if you rename
                        a file.
                        If you ask me, I think it should... :-)
                        >
                        I agree or, at the very least, pop a warning to say that there is now a
                        "mismatch" (for want of a better term) between the class name specified in
                        the page's @Page directive and the actual partial class specified in its
                        associated code-behind file...
                        >
                        --
                        Mark Rae
                        ASP.NET MVPhttp://www.markrae.net
                        no difference :-(

                        There was no namespace so it wasn't necessary but I've defined the
                        class in a namespace now

                        namespace MyNs
                        {
                        public partial class WebForm1 : System.Web.UI.P age
                        {
                        }
                        }

                        Inherits="MyNs. WebForm1"

                        but still nothing :-(

                        anyway ... as the best design still is a separate controlLib for each
                        tier-component I think I'll leave it at that. unless you have another
                        option ?

                        i was just curious about this App_Code thing but as you can imagine,
                        I'm not impressed at all by that functionality..
                        my experience with it? a waste of time.
                        what is supposed the benefit of it?
                        I can only use my product-class when using it in inline script in the
                        aspx-file, so why come up then with the idea of code-behind in the
                        first place?

                        Chris

                        Comment

                        • Juan T. Llibre

                          #13
                          Re: WebAppication project doesn't like separate codefiles

                          re:
                          !i was just curious about this App_Code thing but as you can imagine,
                          !I'm not impressed at all by that functionality..

                          Quite frankly, I'm not too impressed with it, either, primarily from a security viewpoint.
                          Uploading raw code to a server isn't a very secure approach to programming.

                          Also, there's no problems like the one you're encountering.

                          re:
                          !I can only use my product-class when using it in inline script in the aspx-file,
                          !so why come up then with the idea of code-behind in the first place?

                          I've evolved a personal preference which skirts the issues :

                          I compile assemblies with my helper classes ( my DAL layer ) from the command-line,
                          and place the resulting assembly in the /bin directory.

                          It's quite easy then to import my namespace with

                          <%@ Import Namespace="Data Objects" %>

                          ....and instantiating the SQLDATA class is uncomplicated with :

                          Dim RS as New SQLDATA()

                          It works 100% of the time with no fuss.

                          I'd recommend ( depending on your time availability )
                          you dump what you're doing now...and create your own Data Access Layer (DAL).

                          Here's two pages with sample code which will help you get that done quickly :








                          Juan T. Llibre, asp.net MVP
                          asp.net faq : http://asp.net.do/faq/
                          foros de asp.net, en español : http://asp.net.do/foros/
                          =============== =============== ========
                          <cmrchs@gmail.c omwrote in message news:473ffac9-7aa3-4d08-a827-98ff495b7c8b@l6 4g2000hse.googl egroups.com...
                          On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
                          >"Juan T. Llibre" <nomailrepl...@ nowhere.comwrot e in messagenews:eut HlwI9IHA.4140@T K2MSFTNGP02.phx .gbl...
                          >>
                          VS 2008 follows this type of class naming syntax in code-behind files:
                          >>
                          In default.aspx.cs , the code-behind page for Default.aspx...
                          public partial class _Default : System.Web.UI.P age
                          >>
                          Notice the underscore, and notice that the page's class
                          is named for the page name, with an underscore added.
                          >>
                          >Also, the upper-case "D", C# being case-sensitive...
                          >>
                          It looks to me like like renamed an aspx page, but did not change the
                          class name in the code-behind.
                          >>
                          >Indeed. I've been caught out with that on more than one occasion... :-)
                          >>
                          The IDE does not automatically change the class name for you if you rename
                          a file.
                          If you ask me, I think it should... :-)
                          >>
                          >I agree or, at the very least, pop a warning to say that there is now a
                          >"mismatch" (for want of a better term) between the class name specified in
                          >the page's @Page directive and the actual partial class specified in its
                          >associated code-behind file...
                          >>
                          >--
                          >Mark Rae
                          >ASP.NET MVPhttp://www.markrae.net
                          >
                          no difference :-(
                          >
                          There was no namespace so it wasn't necessary but I've defined the
                          class in a namespace now
                          >
                          namespace MyNs
                          {
                          public partial class WebForm1 : System.Web.UI.P age
                          {
                          }
                          }
                          >
                          Inherits="MyNs. WebForm1"
                          >
                          but still nothing :-(
                          >
                          anyway ... as the best design still is a separate controlLib for each
                          tier-component I think I'll leave it at that. unless you have another
                          option ?
                          >
                          i was just curious about this App_Code thing but as you can imagine,
                          I'm not impressed at all by that functionality..
                          my experience with it? a waste of time.
                          what is supposed the benefit of it?
                          I can only use my product-class when using it in inline script in the
                          aspx-file, so why come up then with the idea of code-behind in the
                          first place?
                          >
                          Chris

                          Comment

                          • Mark Rae [MVP]

                            #14
                            Re: WebAppication project doesn't like separate codefiles

                            "Juan T. Llibre" <nomailreplies@ nowhere.comwrot e in message
                            news:O%238CC$K9 IHA.4088@TK2MSF TNGP03.phx.gbl. ..
                            I've evolved a personal preference which skirts the issues :
                            FWIW, I do virtually the same - in fact, I may have pinched the idea from
                            you in the first place... ;-)
                            I'd recommend ( depending on your time availability )
                            you dump what you're doing now...and create your own Data Access Layer
                            (DAL).
                            I couldn't agree more!

                            And dump all the SqlDataSource / ObjectDataSourc e hand-holding stuff at the
                            same time...


                            --
                            Mark Rae
                            ASP.NET MVP


                            Comment

                            • cmrchs@gmail.com

                              #15
                              Re: WebAppication project doesn't like separate codefiles

                              On Aug 2, 4:55 pm, "Juan T. Llibre" <nomailrepl...@ nowhere.comwrot e:
                              re:
                              !i was just curious about this App_Code thing but as you can imagine,
                              !I'm not impressed at all by that functionality..
                              >
                              Quite frankly, I'm not too impressed with it, either, primarily from a security viewpoint.
                              Uploading raw code to a server isn't a very secure approach to programming.
                              >
                              Also, there's no problems like the one you're encountering.
                              >
                              re:
                              !I can only use my product-class when using it in inline script in the aspx-file,
                              !so why come up then with the idea of code-behind in the first place?
                              >
                              I've evolved a personal preference which skirts the issues :
                              >
                              I compile assemblies with my helper classes ( my DAL layer ) from the command-line,
                              and place the resulting assembly in the /bin directory.
                              >
                              It's quite easy then to import my namespace with
                              >
                              <%@ Import Namespace="Data Objects" %>
                              >
                              ...and instantiating the SQLDATA class is uncomplicated with :
                              >
                              Dim RS as New SQLDATA()
                              >
                              It works 100% of the time with no fuss.
                              >
                              I'd recommend ( depending on your time availability )
                              you dump what you're doing now...and create your own Data Access Layer (DAL).
                              >
                              Here's two pages with sample code which will help you get that done quickly :
                              >

                              >

                              >
                              Juan T. Llibre, asp.net MVP
                              asp.net faq :http://asp.net.do/faq/
                              foros de asp.net, en español :http://asp.net.do/foros/
                              =============== =============== ========
                              >
                              <cmr...@gmail.c omwrote in messagenews:473 ffac9-7aa3-4d08-a827-98ff495b7c8b@l6 4g2000hse.googl egroups.com...
                              On Aug 2, 1:22 pm, "Mark Rae [MVP]" <m...@markNOSPA Mrae.netwrote:
                              "Juan T. Llibre" <nomailrepl...@ nowhere.comwrot e in messagenews:eut HlwI9IHA.4140@T K2MSFTNGP02.phx .gbl...
                              >
                              VS 2008 follows this type of class naming syntax in code-behind files:
                              >
                              In default.aspx.cs , the code-behind page for Default.aspx...
                              public partial class _Default : System.Web.UI.P age
                              >
                              Notice the underscore, and notice that the page's class
                              is named for the page name, with an underscore added.
                              >
                              Also, the upper-case "D", C# being case-sensitive...
                              >
                              It looks to me like like renamed an aspx page, but did not change the
                              class name in the code-behind.
                              >
                              Indeed. I've been caught out with that on more than one occasion... :-)
                              >
                              The IDE does not automatically change the class name for you if you rename
                              a file.
                              If you ask me, I think it should... :-)
                              >
                              I agree or, at the very least, pop a warning to say that there is now a
                              "mismatch" (for want of a better term) between the class name specified in
                              the page's @Page directive and the actual partial class specified in its
                              associated code-behind file...
                              >
                              --
                              Mark Rae
                              ASP.NET MVPhttp://www.markrae.net
                              >
                              no difference :-(
                              >
                              There was no namespace so it wasn't necessary but I've defined the
                              class in a namespace now
                              >
                              namespace MyNs
                              {
                              public partial class WebForm1 : System.Web.UI.P age
                              {
                              }
                              }
                              >
                              Inherits="MyNs. WebForm1"
                              >
                              but still nothing :-(
                              >
                              anyway ... as the best design still is a separate controlLib for each
                              tier-component I think I'll leave it at that. unless you have another
                              option ?
                              >
                              i was just curious about this App_Code thing but as you can imagine,
                              I'm not impressed at all by that functionality..
                              my experience with it? a waste of time.
                              what is supposed the benefit of it?
                              I can only use my product-class when using it in inline script in the
                              aspx-file, so why come up then with the idea of code-behind in the
                              first place?
                              >
                              Chris
                              thank you!

                              Chris

                              Comment

                              Working...