MVC无法将lambda表达式转换为类型,因为它不是委托

本文关键字:因为 类型 lambda 转换 表达式 MVC | 更新日期: 2023-09-27 18:16:56

我想知道我是否可以做到这一点,或者有其他的方法来做到这一点?我建立它没有问题,但当我运行它时,它说:

CS1660:无法将lambda表达式转换为类型"DevExpress.Web.Mvc。RoundPanelSettings',因为它不是委托类型

代码:

@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()

猜测吗?

MVC无法将lambda表达式转换为类型,因为它不是委托

发现发生了什么。在SetContent()中不允许使用asp.net标签。正确的做法是:

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

很遗憾,智能感知并没有给出错误的线索。

相关文章: