MVC WebForms Mix Namespacing issue

Last post 11-05-2009 4:59 AM by mad-halfling. 4 replies.

Sort Posts:

  • MVC WebForms Mix Namespacing issue

    11-03-2009, 4:18 AM
    • Member
      577 point Member
    • mad-halfling
    • Member since 12-22-2008, 5:13 AM
    • UK
    • Posts 301

    I've got an MVC app that needs to include a few (not many, but important ones) legacy WebForms pages.  I have put these in a WebForms folder in the root of the app to keep them separate.  The use a common custom control, but I am having problems accessing this - it needs to be accessed in both the web page and the code behind of the webform.  If I create an App_Code/WebFormsControls in the app root, put the file in there and set its NameSpace to "WebFormsControls" I can

    <%@ Register TagPrefix="cus" Namespace="WebFormsControls" Src%>


     

    ok, but I can't then access the "WebFormsControls" namespace from the code-behind.  If I move that folder anywhere else, I can access the NameSpace from the code-behind but the Register doesn't find it.  What am I doing wrong (and please don't say "using WebForms in an MVC app")?

    Thanks

    MH

    Please remember to mark replies as answers if you find them useful =8)
  • Re: MVC WebForms Mix Namespacing issue

    11-03-2009, 1:26 PM
    • Contributor
      5,639 point Contributor
    • ricka6
    • Member since 06-25-2008, 6:04 PM
    • Redmond
    • Posts 915
    • AspNetTeam
      Moderator
  • Re: MVC WebForms Mix Namespacing issue

    11-03-2009, 5:20 PM
    • Member
      577 point Member
    • mad-halfling
    • Member since 12-22-2008, 5:13 AM
    • UK
    • Posts 301

    The routing is all fine, it's accessing the custom code that's the issue.  I have had a look through the PDF quickly but I can't see anything in there either, but I'll have a bit more of a look later this week.

    Please remember to mark replies as answers if you find them useful =8)
  • Re: MVC WebForms Mix Namespacing issue

    11-04-2009, 10:36 PM

    Hi,

    If you mixed webform and mvc, the following link mentioned by rick would be very helpful for us.

    http://www.packtpub.com/article/mixing-asp.net-webforms-and-asp.net-mvc

  • Re: MVC WebForms Mix Namespacing issue

    11-05-2009, 4:59 AM
    • Member
      577 point Member
    • mad-halfling
    • Member since 12-22-2008, 5:13 AM
    • UK
    • Posts 301

    That doesn't seem to address namespacing.  My strange problem is that I have 2 classes in the same file and namespace (WebFormsControls).  If the file is in a particular location (I made a /App_Code/WebFormsControls directory) in the project, a webform can see the first class but its code-behind can't see the 2nd, and if I move the file to a different location (/WebForms/CustomClasses) within the project the webform can't see the first class but the code-behind can now see the 2nd class.  Can anyone explain this?

    Please remember to mark replies as answers if you find them useful =8)
Page 1 of 1 (5 items)