2015-10-15 47 views
1

其上來這樣追加與HTML文件的陣列

一旦我從以往的動作發送IEnumerable<ProductsPropertiesVM> model數據,我可以使用上述方法

一旦我上調試模式下運行這通常那些selectedIDs出現過濾一些selectedIDs這樣

enter image description here

我需要使用下面的方法來發送陣列

[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(); 
} 

所以我需要把那些selectedIDsmyhtml.html文件

如果問,在另一種方式, (如果我認爲這selectedIDs可以作爲數組發送)
我想知道我們如何可以追加以上selectedIDs陣列與editor.LoadHtml("path")

+0

追加它們作爲URL參數。 – vijayP

+0

該怎麼做?但在這裏它不只是一個單一的值,實際上它的一組值 – kez

+0

將數組轉換爲json並通過它 – 2015-10-15 12:50:52

回答

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); 
    }); 
+0

其實我正在加載這個HTML文件到富文本編輯器的內容,但我會檢查你的答案 – kez