AAlferez
AAlferez

Reputation: 1492

MVC Cannot convert lambda expression to type because it is not a delegate

I was wondering if I can do this or is there other way to do it? I build it without problems but when I run it it says:

CS1660: Cannot convert lambda expression to type 'DevExpress.Web.Mvc.RoundPanelSettings' because it is not a delegate type

Code:

@Html.DevExpress().RoundPanel(RPsettings =>
{
    RPsettings.Name = "rpnlNewUpdateConfigs";
    RPsettings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
    RPsettings.ShowHeader = false;
    RPsettings.SetContent(() =>
        {
            Html.DevExpress().CallbackPanel(CBsettings =>
            {
                CBsettings.Name = "cbpnlNewUpdateConfigs";
                CBsettings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
                CBsettings.CallbackRouteValues = new { Controller = "Storage", Action = "Storage" };
                CBsettings.SetContent(() =>
                    {
                        @<table>
                            <tr>
                                <td>
                                    <table>
                                        <tr>
                                            <td>&nbsp;
                                            </td>
                                            <td>Type:
                                            </td>
                                            <td>
                                                @Html.DevExpress().ComboBox(cboxsettings =>
                                                {
                                                    cboxsettings.Name = "cbType";
                                                    cboxsettings.Width = 180;
                                                    cboxsettings.SelectedIndex = -1;
                                                    cboxsettings.Properties.ValueType = typeof(string);
                                                    cboxsettings.Properties.Items.Add("Path");
                                                }).GetHtml();
                                            </td>
                                            <td>&nbsp;
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>;
                        Html.DevExpress().Label(L1settings =>
                        {
                            L1settings.Name = "ErrorLabel1";
                            L1settings.Text = "Label1";
                        }).Render();
                        Html.DevExpress().Label(L2settings =>
                        {
                            L2settings.Name = "ErrorLabel2";
                            L2settings.Text = "Label2";
                        }).Render();
                    });
            }).GetHtml();
        });
}).GetHtml()

Any guesses?

Upvotes: 3

Views: 7215

Answers (1)

AAlferez
AAlferez

Reputation: 1492

Found what happens. The asp.net tags are not allowed in the SetContent() that way. The correct way to do it is:

CBsettings.SetContent(() => {
    ViewContext.Writer.Write("<h1>Hello World</h1>");

    ...

});

So sad the intellisense doesn't give a clue about what is wrong.

Upvotes: 2

Related Questions