小编Man*_*yak的帖子

使用jquery将div转换为图像数据


我有一个HTML页面.我有一个按钮,每当我点击这个按钮,它应该将整个html页面转换为数据图像.我通过使用html2canvas实现了这一点,如下所示:

html2canvas([document.getElementById('form1')], {
        onrendered: function (canvas) {
            var imageData = canvas.toDataURL('image/jpeg',1.0); 
     }
    });
Run Code Online (Sandbox Code Playgroud)

它给了我图像数据,但没有复选框和单选按钮.那么有没有办法使用jquery或javascript将html页面转换为图像数据?
如果有,请帮我解决这个问题.
先感谢您.

html javascript css jquery html2canvas

5
推荐指数
1
解决办法
2万
查看次数

如何编写LINQ查询以使用C#从另一个对象获取对象?

我将以下foreach循环转换为LINQ语句.

foreach (Plant plant in Plant.ListPlants)
{
    foreach (Program program in plant.GetAllPrograms())
    {
        if (program.GetProfitCenter() != null)
        {
            foreach (CostCenter costCenter in program.GetProfitCenter().GetAllCostCenters())
            {
                foreach (Account account in costCenter.GetAccounts())
                {
                    if (account.Code == Code)//Code is a parameter
                    {
                        return account;
                    }
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

只要不存在此类帐户代码,结果应返回null.请帮我构建上述循环的LINQ.

.net c# linq loops object

2
推荐指数
1
解决办法
89
查看次数

图像未显示从系统硬盘读取

图像未显示从系统硬盘读取.

在我的应用程序中,我想在名为附件的文件夹中读取存储的图像.要运行该应用程序,用户必须在其c盘中创建一个名为attachments的文件夹.存储的文件的路径如下.C:\ Attachments\test.jpg.我想动态读取存储在此文件夹中的图像.我能够从数据库中获取文件的名称.图像不会显示在图像控件中.

我尝试了以下方法:

ImageID. ImageURL= “C:\Attachments\test.jpg”

var url = Server.MapPath("~/Attachments / test.jpg");
  ImageID.ImageUrl = url;

ImageID.ImageUrl = VirtualPathUtility.ToAbsolute("~/Attachments ") + "/test.jpg"
Run Code Online (Sandbox Code Playgroud)

当图像存储在系统磁盘中且文件夹不在Web应用程序路径中时,在图像控件中显示图像的确切方法是什么.

asp.net image

1
推荐指数
1
解决办法
1386
查看次数

搜索键匹配C#中列表中的值

我有一份清单.

var dicAclWithCommonDsEffectivity = new Dictionary<string, List<int>>();
var list1 = new List<int>(){1,2,3};
var list2 = new List<int>(){2,4,6};
var list3 = new List<int>(){3,7,6};
var list4 = new List<int>(){8,7,6};

dicAclWithCommonDsEffectivity.Add("ab",list1);
dicAclWithCommonDsEffectivity.Add("bc",list2);
dicAclWithCommonDsEffectivity.Add("cd",list3);
dicAclWithCommonDsEffectivity.Add("de",list4);
Run Code Online (Sandbox Code Playgroud)

我想获取字典中的键,其中至少有一个匹配值与当前键列表.键"ab"(第一个列表).我应该得到:"ab","bc" and "cd".因为这些列表包含{1,2,3}中的一个匹配元素

有没有办法没有循环遍历字典值列表中的每个项目.

c# dictionary

1
推荐指数
1
解决办法
3163
查看次数

将项目添加到字典中的现有列表

我有一本字典如下

var dicAclWithCommonDsEffectivity = new Dictionary<string, List<int>>();
Run Code Online (Sandbox Code Playgroud)

我有一个如下列表

var dsList=new List<int>();
Run Code Online (Sandbox Code Playgroud)

对于中的每个项目,dsList我将在dicAclWithCommonDsEffectivity字典中搜索列表中的匹配值。如果我找到匹配项,我将获取其密钥并组合所有密钥形成一个新密钥。我将创建一个新列表并添加项目。

foreach (int i in dsList)
{
    var aclWithmatchingDS = dicAclWithCommonDsEffectivity.Where(x => x.Value.Contains(i)).Select(x=>x.Key);
    if (aclWithmatchingDS.Count() > 0)
    {
        string NewKey= aclWithmatchingDS.key1+","aclWithmatchingDS.key2 ;

        //if NewKey is not there in dictionary 
        var lst=new List<int>(){i};
        //Add item to dictionary
        //else if item is present append item to list
        //oldkey,{oldlistItem,i};

    }
}
Run Code Online (Sandbox Code Playgroud)

对于 dsList 中的下一个项目,如果有匹配的键,那么我必须将该项目添加到新字典内的列表中。

如何在不创建新列表的情况下将新项目添加到字典中的列表中。

c# linq

1
推荐指数
1
解决办法
6901
查看次数

标签 统计

c# ×3

linq ×2

.net ×1

asp.net ×1

css ×1

dictionary ×1

html ×1

html2canvas ×1

image ×1

javascript ×1

jquery ×1

loops ×1

object ×1