Page view counter

Html.RenderUserControl is not found at MVC Preview 5 build

Last post 09-04-2008 7:41 AM by daggmano. 7 replies.

Sort Posts:

  • Html.RenderUserControl is not found at MVC Preview 5 build

    09-02-2008, 2:18 PM
    • Loading...
    • moudud.hassan
    • Joined on 08-29-2008, 12:12 PM
    • Posts 3
    • Points 0

    Today I have just migrated my code from mvc preview 2 to mvc preiview 5. I can see some of the html helper methods are not present anymore. Same is the case for Html.RenderUserControl. Is there any for mvc preview 5 to have the same effect of Html.RenderUserControl?

    Well obviously I can put a panel inside the view page/view content page and add a UserControl programatically. As well I can return a View for the user control from a controller. But not considering these two option can i have the same effect of Html.RenderUserControl at mvc preview 5 in some different way?

  • Re: Html.RenderUserControl is not found at MVC Preview 5 build

    09-02-2008, 3:11 PM
    • Loading...
    • detroitpro
    • Joined on 09-02-2008, 7:06 PM
    • Posts 2
    • Points 4

     ditto..I don't want to go back to Web Forms...no panels..yuck.....

    seriously, I have a large project that makes heavy use of RenderUserControl....what is a lead developer to do?

  • Re: Html.RenderUserControl is not found at MVC Preview 5 build

    09-02-2008, 3:20 PM
    • Loading...
    • detroitpro
    • Joined on 09-02-2008, 7:06 PM
    • Posts 2
    • Points 4

     Ok, so user controls are not exactly so MVCish....and I am hearing a lot of chatter about partial views....am I supposed to refactor all my UCs into PVs? and use html.renderpartialview ?

  • Re: Html.RenderUserControl is not found at MVC Preview 5 build

    09-02-2008, 3:49 PM
    • Loading...
    • levib
    • Joined on 07-23-2007, 7:50 PM
    • Redmond, WA
    • Posts 685
    • Points 3,665
    • AspNetTeam

    <% Html.RenderPartial("~/Views/Shared/MyControl.ascx") %>
    <% Html.RenderPartial("MyControl") %>

    You can specify the full path to your user control as in the first example.  Or, if your user control is in the ~/Views/Shared folder, you can use the second example.

  • Re: Html.RenderUserControl is not found at MVC Preview 5 build

    09-02-2008, 9:01 PM
    • Loading...
    • daggmano
    • Joined on 06-18-2008, 8:25 PM
    • Sydney, Australia
    • Posts 23
    • Points 28
    I think I must be missing something (on account of it not working...). I had a few ViewUserControl derived .ascx files that I was including using RenderUserControl. I'm fine about now switching over to RenderPartial, but what do I need to do to my .ascx files to get them to work as before? I'm currently getting a HttpUnhandledException error. Thanks in advance.
  • Re: Html.RenderUserControl is not found at MVC Preview 5 build

    09-02-2008, 9:03 PM
    • Loading...
    • levib
    • Joined on 07-23-2007, 7:50 PM
    • Redmond, WA
    • Posts 685
    • Points 3,665
    • AspNetTeam

    Can you post the error message and stack trace?

  • Re: Html.RenderUserControl is not found at MVC Preview 5 build

    09-02-2008, 9:11 PM
    • Loading...
    • daggmano
    • Joined on 06-18-2008, 8:25 PM
    • Sydney, Australia
    • Posts 23
    • Points 28

    Here'tis

    System.Web.HttpUnhandledException was unhandled by user code Message="Exception of type 'System.Web.HttpUnhandledException' was thrown."

    Source="System.Web"
    ErrorCode=-2147467259

    StackTrace: at System.Web.UI.Page.HandleError(Exception e)
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    at System.Web.UI.Page.ProcessRequest()
    at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)
    at System.Web.UI.Page.ProcessRequest(HttpContext context)
    at System.Web.Mvc.ViewPage.RenderView(ViewContext viewContext)
    at System.Web.Mvc.ViewUserControl.RenderView(ViewContext viewContext)
    at System.Web.Mvc.WebFormView.RenderViewUserControl(ViewContext context, ViewUserControl control)
    at System.Web.Mvc.WebFormView.Render(ViewContext viewContext, TextWriter writer)
    at System.Web.Mvc.HtmlHelper.RenderPartialInternal(String partialViewName, ViewDataDictionary viewData, IViewEngine engine)
    at System.Web.Mvc.HtmlHelper.RenderPartial(String partialViewName)
    at ASP.views_home_index_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\Users\darren.oster\Documents\Visual Studio 2008\Projects\GlenmoreParkAnglicanWebsite\GPACWeb\Views\Home\Index.aspx:line 78
    at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
    at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
    at System.Web.UI.Page.Render(HtmlTextWriter writer)
    at System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer)
    at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
    at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
    at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    InnerException: System.Web.HttpException Message="Multiple controls with the same ID '__Page' were found. Trace requires that controls have unique IDs."
    Source="System.Web"
    ErrorCode=-2147467259
    StackTrace: at System.Web.TraceContext.AddNewControl(String id, String parentId, String type, Int32 viewStateSize, Int32 controlStateSize)
    at System.Web.UI.Control.BuildProfileTree(String parentId, Boolean calcViewState)
    at System.Web.UI.Page.BuildPageProfileTree(Boolean enableViewState)
    at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

    InnerException:

  • Re: Html.RenderUserControl is not found at MVC Preview 5 build

    09-04-2008, 7:41 AM
    • Loading...
    • daggmano
    • Joined on 06-18-2008, 8:25 PM
    • Sydney, Australia
    • Posts 23
    • Points 28
    I found the issue: I created a new MVC project in VS and compared web.config files - there was a line in my web.config,

    <trace enabled="true" localOnly="false" />

    that wasn't in the new project.  I removed this line, and everything started working again.

    Not sure how it got in there in the first place, but there you go
Page 1 of 1 (8 items)