【问题标题】:Append an array with HTML file附加一个带有 HTML 文件的数组
【发布时间】:2016-01-13 22:18:53
【问题描述】:

它是这样来的

一旦我从先前的操作发送IEnumerable<ProductsPropertiesVM> model 数据,我可以使用上述方法过滤一些选定的ID

一旦我在调试模式下运行它,selectedIDs 通常会像这样显示

我需要使用以下方法发送该数组

[HttpGet]  
[ValidateInput(false)]  
public ActionResult Create_Brochure(IEnumerable<ProductsPropertiesVM> model)  
{  
    // to access to all the ID's of the selected items, for example  
    IEnumerable<int> selectedIDs = model.Where(x => x.IsChecked).Select(x => x.Property_ID);  


    PrepairEditor(delegate (Editor editor)  
    {  
        editor.LoadHtml("~/brochuretemplates/myhtml.html");  
    });  

    return View();  
}

所以我需要将那些selectedIDs 发送到myhtml.html 文件

如果换个方式问, (如果我认为 selectedIDs 可以作为数组发送)
我想知道我们如何在 selectedIDs 数组上方附加 editor.LoadHtml("path")

【问题讨论】:

  • 将它们作为 URL 参数附加。
  • 怎么做?但这里它不仅仅是一个值,实际上是它的一组值
  • 将数组转换为json并传递
  • 在你的数组上做一个连接,使它看起来像这样:1,2,然后将它传递到 url:editor.LoadHtml("~/brochuretemplates/myhtml.html?selectedIDs=1,2 ");
  • @vijayP 在下面添加了一个答案,这就是我的建议。这应该对你有用。

标签: c# jquery html asp.net-mvc append


【解决方案1】:

在您的控制器操作中尝试以下代码:

    IEnumerable<int> selectedIDs = model.Where(x => x.IsChecked).Select(x => x.Property_ID);  

    string ids = string.Join(",", selectedIDs );

    PrepairEditor(delegate (Editor editor)  
    {  
        editor.LoadHtml("~/brochuretemplates/myhtml.html?selectedIDs="+ids );  
    }); 

【讨论】:

  • 实际上我正在将此 html 文件加载到富文本编辑器内容中,但是我会检查您的答案
猜你喜欢
  • 2011-10-25
  • 1970-01-01
  • 1970-01-01
  • 2018-04-28
  • 2018-01-09
  • 1970-01-01
  • 1970-01-01
  • 2019-06-08
  • 1970-01-01
相关资源
最近更新 更多