редактор для проверки в Inte rnet Explorer - PullRequest
0 голосов
/ 16 января 2020

Я работаю над проектом asp. net mvc.

Я передаю ввод пользователя из представления в контроллер с помощью помощника html @ html .editorfor .

Поле модели является строкой, но входные данные должны быть динамического типа (см. Код ниже) и основываться на различных проверках, таких как min max и c.

работа с браузером Chrome. Но я должен написать код для браузера inte rnet explorer, и он не поддерживает это. Как я могу получить, что logi c проверка также для inte rnet explorer?

код:

-Модель (часть): publi c RecipeParameter () {...

    private String _Value = String.Empty;
...
    }
  • Вид (часть):

    ...

    @ model BASF_SHG.Models.CollectionRecipe

                                                    @{
                                                        string min = Model.recipe.ParameterGroupsArray[i].ParameterArray[k].MachineMin;
                                                        string max = Model.recipe.ParameterGroupsArray[i].ParameterArray[k].MachineMax;
    
                                                        if (min == "")
                                                        {
                                                            min = "-1000000";
                                                        }
                                                        if (max == "")
                                                        {
                                                            max = "1000000";
                                                        }
    
                                                        @Model.recipe.ParameterGroupsArray[i].ParameterArray[k].DataType
    
                                                        if (Model.recipe.ParameterGroupsArray[i].ParameterArray[k].DataType == "Integer" || Model.recipe.ParameterGroupsArray[i].ParameterArray[k].DataType == "MxInteger")
                                                        {
    
                                                            @Html.EditorFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].Value, new { htmlAttributes = new { @min = min, @max = max, @Type = "number", @class = "form-control editorField" } })
                                                            @Html.ValidationMessageFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].Value, "", new { @class = "text-danger" })
    
                                                        }
    
                                                        else
                                                        if (Model.recipe.ParameterGroupsArray[i].ParameterArray[k].DataType == "Float" || Model.recipe.ParameterGroupsArray[i].ParameterArray[k].DataType == "MXFloat")
                                                        {
    
    
    
                                                            @Html.EditorFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].Value, new { htmlAttributes = new { @class = "form-control editorField", @min = min, @max = max, @Type = "number", @step = ".001" } })
                                                            @Html.ValidationMessageFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].Value, "", new { @class = "text-danger" })
                                                        }
                                                        else
                                                        if (Model.recipe.ParameterGroupsArray[i].ParameterArray[k].DataType == "Boolean" || Model.recipe.ParameterGroupsArray[i].ParameterArray[k].DataType == "MXBoolean")
                                                        {
    
                                                            <label style="color:black;">False @Html.RadioButtonFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].Value, "False")</label>
    
                                                            <label style="color:black;">True @Html.RadioButtonFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].Value, "True")</label>
    
    
                                                        }
                                                        else
                                                        if (Model.recipe.ParameterGroupsArray[i].ParameterArray[k].DataType == "String" || Model.recipe.ParameterGroupsArray[i].ParameterArray[k].DataType == "MXString")
                                                        {
                                                            @Html.EditorFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].Value, new { htmlAttributes = new { @class = "form-control editorField", Type = "text" } })
                                                            @Html.ValidationMessageFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].Value, "", new { @class = "text-danger" })
    
    
                                                        }
                                                        else
                                                        if (Model.recipe.ParameterGroupsArray[i].ParameterArray[k].Name == null || Model.recipe.ParameterGroupsArray[i].ParameterArray[k].Name == "")
                                                        {
                                                            <label style="background-color:grey;">Attention. Recipe is corrupt and will be deleted. </label>
    
                                                            @Html.HiddenFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].Name)
                                                        }
                                                        else
                                                        {
    
    
                                                            <label style="background-color:grey;">Attention. Recipe is corrupt and will be deleted. </label>
    
                                                            @Html.HiddenFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].Name)
    
                                                        }
    
    
                                                        @Html.HiddenFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].Name)
                                                        @Html.HiddenFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].DataType)
                                                        @Html.HiddenFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].IsMasterRecipeParameter)
                                                        @Html.HiddenFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].IsCDataValue)
                                                        @Html.HiddenFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].OperatorMin)
                                                        @Html.HiddenFor(model => model.recipe.ParameterGroupsArray[i].ParameterArray[k].OperatorMax)
    
    
                                                    }
    
    
                                                </div>
    

    ...

Как вы можете видеть, я пытаюсь установить валидацию в зависимости от типа данных модели. Inte rnet Explorer не поддерживает это. Что я могу сделать? Напишите мою собственную валидацию? Но как это должно выглядеть?

...