0

我的理解有差距。我有两个视图屏幕,一个成功地从 devexpress 选择网格中获取了一个值,但一个没有......而且我不明白我在做什么不同。

当我使用萤火虫时,我找不到模型在 DOM 中的设置位置。

以下作品:

using System;
using System.Collections.Generic;
using System.Linq;

using System.ComponentModel.DataAnnotations;

namespace EtracsWeb.Areas.IO.Models
{
    public class VoyageInputModel
    {
        [Required(ErrorMessage = "Value must be supplied")]
        [Display(Name = "Show Received Voyages")]
        public bool ShowReceivedVoyages { get; set; }

        public string VoyageIDS { get; set; }

    }
}

在视图中使用(有效)......这是视图的一个片段:

@using EtracsWeb.Areas.IO.Models;
@model VoyageInputModel

@{
    ViewBag.Title = "Voyage (Receive/UnReceive/etc..)";
    Layout = "~/Views/Shared/_LayoutMenu.cshtml";
}

@* MUST go here and NOT at end or code won't work *@
<script type="text/javascript">

    //This is the value from the devExpress Selection Grid...
    function OnSelectionChanged(s, e) {
        s.GetSelectedFieldValues("VoyageID", GetSelectedFieldValuesCallback);
    }

    //This is the value from the InputModel...notice it is different...
    //This is why we need this two step process.
    function GetSelectedFieldValuesCallback(values) {
        //  voyage_ids = values;
        //alert(values);
        document.getElementById('VoyageIDS').value = values;
        //alert(document.getElementById('VoyageIDS').value)
    }
</script>

请注意,我将 OnSelection 中的值更改为一个变量,并在 inputModel 中设置为不同的名称......这一切都有效......

我正在尝试使用第二个视图来执行此操作,并且代码在我尝试使用 getElementbyID 访问模型中的变量时终止。最初我试图使用 int ......但我将其切换为字符串。 ..但两者都不起作用....

DOM 中的模型到底在哪里?如何使用 Firebug 查看@model 值(来自 asp.net mvc)???

我在第二个窗口上出错的任何想法?

这是第二个输入模型:

using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel.DataAnnotations;

namespace EtracsWeb.Areas.Vehicle.Models
{
    public class BookMarkListInputModel
    {
        public string SelectedBookMarkID { get; set; }
        public int                   BookMarkID  { get; set; }
        public IEnumerable<BookMark> BookMarks          { get; set; }
    }
}

和第二个视图片段:

@using EtracsWeb.Areas.Vehicle.Models
@model BookMarkListInputModel

@{
    ViewBag.Title = "List";
    Layout = "~/Views/Shared/_LayoutMenu.cshtml";
}

@* MUST go here and NOT at end or code won't work *@
<script type="text/javascript">

    //This is the value used in the DevExpress Selection Grid
    function OnSelectionChanged(s, e) {
        s.GetSelectedFieldValues("BookMarkID", GetSelectedFieldValuesCallback);
    }

    //This is the variable from the InputModel...notice it can be different
    //So we need to have this two step process.
    function GetSelectedFieldValuesCallback(values) {
        alert(values);
        document.getElementById('SelectedBookMarkID').value = values;
        alert(document.getElementById('SelectedBookMarkID').value)
    }


    function Success(data) {
        //   alert(data.ReturnMessage);
        id1.innerHTML = data.ReturnMessage;
    }

</script>
4

0 回答 0