2

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?

Gabriele Petrioli
  • 191,379
  • 34
  • 261
  • 317
ekkis
  • 9,804
  • 13
  • 55
  • 105

2 Answers2

2

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.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • I did try your suggestion and it worked, calling it as a partial view, however the control generates obscene output and created scrollbars in my div with a bunch of empty space... not sure wtf. I ended up going with a jQuery solution but thanks for the useful reply. – ekkis May 18 '11 at 04:50
1

The Razor compatible version of the Obout MVC ComboBox will be available soon: http://forum.obout.com/yaf_postsm2112_Examples-pleease.aspx#post2112

Chris
  • 31
  • 1