title: Why won't my ascx file pick up my code behind properties?
body: <p>My web app is a solution built on top of another solution. The base solution is meant to be a platform for multiple products. For the most part, this works fine, but weird things happen when I create product specific views.</p>
  
  <p>I am using <code>ViewUserControl&lt;SomeViewModel&gt;</code> for my code behind class. In my code behind, I have access to <code>this.Model</code> and all the other goodies I'd expect from this class. But in my ascx file, I get red squiggley lines when I try to access <code>this.Model</code> or other properties defined in <code>ViewUserControl</code>. I also get red squiggley lines when I try to access properties defined directly in my code behind.</p>
  
  <p>What's more interesting is, I don't get any real errors from this. The view renders just fine at run time and does not give me any build errors. But my ascx file <strong>thinks</strong> there will be errors. If I create <strong>the exact same view</strong> in the platform namespaces, it works fine. No red squiggles.</p>
  
  <p>I find this to be really annoying. It's not a show stopper by any means, but if I'm going to be using an IDE with intellisense and all that jazz, I'd sure like it to work properly, and pick up the properties that are supposed to be there.</p>
  
  <p>Has anyone else run into this? Do you know of a way to fix this?</p>
  
  <p>Thanks!</p>
  
  <p><strong>Edit</strong></p>
  
  <p>It was requested that I post some code. Here's the code behind:</p>
  
  <pre><code>namespace MyProject.MyProduct.Web.Views
  {
      public class EditSearch : ViewUserControl&lt;SearchResultsViewModel&gt;
      {
          public bool IsSearchTypeA()
          {
              ...............
          }
  
          public bool IsSearchTypeB()
          {
              ...............
          }
      }
  }
  </code></pre>
  
  <p>And here's my ascx:</p>
  
  <pre><code>&lt;% 
      if (!this.IsSearchTypeB())
      { 
          string categoryPageTitle = this.Model.SearchWidgetParameters.Search.CategoryPageTitle;
          string categoryPageUrl = this.Model.SearchWidgetParameters.Search.Filters.CategoryPageUrl;
  
          if (!string.IsNullOrEmpty(categoryPageUrl))
          {
              %&gt; &lt;div id="coid_website_backtoCategoryPageLink"&gt; &lt;%
  
              string tocGuid = this.Model.SearchWidgetParameters.Search.Filters.TocGuid;
  
              if (!string.IsNullOrEmpty(tocGuid))
              {
                  categoryPageUrl += "?guid=" + tocGuid;
              }
  
              var backToLink = new HyperLink();
  
              if (this.IsSearchTypeA())
              {
                  backToLink.Text = "Edit Search";
              }
              else
              {
                  backToLink.Text = "Back to " + TranslatedHtmlTextWriter.Translate(categoryPageTitle);
              }
  
              backToLink.NavigateUrl = TransactionOperations.AddContextToUrl(categoryPageUrl.StartsWith("/Browse/") ? categoryPageUrl : "/Browse/" + categoryPageUrl,
                                                                              WebsiteTransitionType.Default, // Requested: CategoryPage
                                                                              TransactionOperations.DefaultContextData);
              backToLink.RenderControl(this.Writer);
              %&gt;
                  &lt;/div&gt;
              &lt;%
          } 
      }
  %&gt;
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>For those of you who are telling me that ASP.NET MVC cannot or does not use code behind, I'm sorry but this is horse hockey. This project has existed for years and there is a widely used product that runs on it. My product is only just recently jumping onto the Platform. The Platform solution uses code behind all over the place, and it works fine. In fact, it works fine at runtime in my product's solution as well, I just have the problem that my ascx file doesn't seem to know about my code behind. Furthermore, <code>ViewUserControl</code> is a <code>System.Web.MVC</code> class. Are you still going to tell me that code behind isn't used in ASP.NET MVC?</p>