Search code examples
asp.net-mvc-3razorobout

Response out of sequence


I'm using the Obout.com MVC controls and have included the following code in one of my views:

@{
   Html.Obout(new ComboBox("Languages") {
       Width = 175,
       SelectedIndex = (int) ViewData["DefaultLanguage"] - 1,
       ShowSelectedImage = true
       }
   );
}

I'm doing it that way because my original attempt failed:

@Html.Obout(new ComboBox("Languages") { Width = 175, SelectedIndex = (int) ViewData["DefaultLanguage"] - 1, ShowSelectedImage = true })

...it seems I need to use the @{} structure. However, when the output gets generated, the code that Html.Obout() generates comes ahead of all other output. the <!DOCTYPE html> and the real page follows the control's output. is this a function of the @{} structure, or is it some issue with the control itself?


Solution

  • It looks like this method was designed for ASPX views and writes directly to HttpContextBase.Response.OutputStream.

    Since Razor buffers its output in WebPageBase.Output, you will not easily be able to use these helpers in Razor.
    You could put them in a separate ASCX partial view, and they will work.

    Depending on how the helpers are implemented, you may be able to force them to write to WebPageBase.Output; since I don't use Obout, I don't know.