小编Ama*_*ure的帖子

System.Array.CopyTo()和System.Array.Clone()之间的区别

System.Array.CopyTo()和之间有什么区别System.Array.Clone()

.net c# arrays .net-2.0

74
推荐指数
5
解决办法
9万
查看次数

触发"click"和"enter"上的事件

我的网站上有一个搜索框.目前,用户必须单击该框旁边的提交按钮才能通过jquery的帖子进行搜索.我想让用户也按Enter进行搜索.我怎样才能做到这一点?

JQUERY:

$('document').ready(function(){
    $('#searchButton').click(function(){
        var search = $('#usersSearch').val();
        $.post('../searchusers.php',{search: search},function(response){
            $('#userSearchResultsTable').html(response);
        });
    });
});
Run Code Online (Sandbox Code Playgroud)

HTML:

<input type='text' id='usersSearch'  /><input type='button' id='searchButton' value='search' />
Run Code Online (Sandbox Code Playgroud)

jquery jquery-selectors

70
推荐指数
3
解决办法
12万
查看次数

C# - 获取不包括隐藏文件的文件列表

Directory.GetFiles()返回所有文件,甚至是那些标记为隐藏的文件.有没有办法获取排除隐藏文件的文件列表?

.net c# file

65
推荐指数
3
解决办法
5万
查看次数

安装后,Windows服务未出现在服务列表中

我使用Visual Studio 2008在c#中创建了一个Windows服务我几乎遵循这个:http: //www.codeproject.com/KB/dotnet/simplewindowsservice.aspx

我按照文章中的指示创建了一个安装项目,并运行它...它将我的服务安装到c:\ program files\product等....但是,它不会出现在服务列表中.

我错过了什么?

c# windows-services setup-deployment visual-studio-2008

54
推荐指数
3
解决办法
8万
查看次数

如何检查下拉列表是否已禁用?

使用jquery我如何简单地检查它是否只读?

这就是我想要的..

$("#item").keydown(function (event) {
     //alert(event.keyCode);
     if (event.keyCode == 13) {
         $("#ok").click();               
         if ($('#dropLength').prop("disabled") == false) {
             $("#dropLength").focus();
             return;
         }
         if ($('#dropUnit').prop("disabled") == false) {
             $("#dropUnit").focus();
             return;
         }
         $("#qty").focus();                
         return ;
     }
 });
Run Code Online (Sandbox Code Playgroud)

使用jquery将下拉列表设置为readonly:

if ($('#dropLength').find('option').length <= 1) {
      $('#dropLength').attr("disabled", "disabled");
}
if ($('#dropUnit').find('option').length <= 1) {
      $('#dropUnit').attr("disabled", "disabled");
}   
Run Code Online (Sandbox Code Playgroud)

jquery

54
推荐指数
2
解决办法
11万
查看次数

将枚举序列化为字符串

我有一个枚举:

public enum Action {
    Remove=1,
    Add=2
}
Run Code Online (Sandbox Code Playgroud)

一节课:

[DataContract]
public class Container {
    [DataMember]
    public Action Action {get; set;}
}
Run Code Online (Sandbox Code Playgroud)

当将Container的实例序列化为json时,我得到:( {Action:1}如果Action被删除).

我想得到:( {Action:Remove}而不是int我需要ToString形式的枚举)

我可以在不增加其他成员的情况下这样做吗?

c# json datacontract

47
推荐指数
4
解决办法
4万
查看次数

从不同步的代码块调用对象同步方法.Mutex.Release()的例外情况

我找到了关于这个例外的不同文章,但没有一个是我的情况.这是源代码:

class Program
{

    private static Mutex mutex;
    private static bool mutexIsLocked = false;
    static void Main(string[] args)
    {

        ICrmService crmService = 
            new ArmenianSoftware.Crm.Common.CrmServiceWrapper(GetCrmService("Armsoft", "crmserver"));
        //Lock mutex for concurrent access to workflow
        mutex = new Mutex(true, "ArmenianSoftware.Crm.Common.FilterCtiCallLogActivity");
        mutexIsLocked = true;

        //Create object for updating filtered cti call log
        ArmenianSoftware.Crm.Common.FilterCtiCallLog filterCtiCallLog =
            new ArmenianSoftware.Crm.Common.FilterCtiCallLog(crmService);
        //Bind events
        filterCtiCallLog.CtiCallsRetrieved += new EventHandler<ArmenianSoftware.Crm.Common.CtiCallsRetrievedEventArgs>(filterCtiCallLog_CtiCallsRetrieved);

        //Execute filter
        try
        {
            filterCtiCallLog.CreateFilteredCtiCallLogSync();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            if (mutexIsLocked)
            {
                mutexIsLocked = false; …
Run Code Online (Sandbox Code Playgroud)

.net c# multithreading mutex

24
推荐指数
4
解决办法
5万
查看次数

获取包含特定类的第一个匹配的祖先

我试图迭代到包含类'sys-form-row'的第一个祖先.

我能够使用以下内容获取包含class ="sys-form-row"的行:objBack =

$('#txtMyBox2').parent().parent();
Run Code Online (Sandbox Code Playgroud)

这看起来非常笨拙.我想做的是这样的事情:

$('#txtMyBox2').parents('.sys-form-row'); 或者甚至$('#txtMyBox2').closest('.sys-form-row');两者都失败了,如果应用额外的div嵌套,我的当前方法将不会始终有效.任何帮助将非常感激.

jquery parents jquery-selectors closest

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

如何检查WebClient请求是否有404错误

我有一个程序,我写的是下载到文件.第二个文件不是必要的,只包括一些时间.如果未包含第二个文件,则会返回HTTP 404错误.

现在,问题是当返回此错误时,它将结束整个程序.我想要的是继续该程序并忽略HTTP错误.所以,我的问题是如何HTTP 404WebClient.DownloadFile请求中捕获错误?

这是当前使用的代码::

WebClient downloader = new WebClient();
foreach (string[] i in textList)
{
    String[] fileInfo = i;
    string videoName = fileInfo[0];
    string videoDesc = fileInfo[1];
    string videoAddress = fileInfo[2];
    string imgAddress = fileInfo[3];
    string source = fileInfo[5];
    string folder = folderBuilder(path, videoName);
    string infoFile = folder + '\\' + removeFileType(retrieveFileName(videoAddress)) + @".txt";
    string videoPath = folder + '\\' + retrieveFileName(videoAddress);
    string imgPath = folder + '\\' + retrieveFileName(imgAddress);
    System.IO.Directory.CreateDirectory(folder);
    buildInfo(videoName, videoDesc, …
Run Code Online (Sandbox Code Playgroud)

c# webclient

18
推荐指数
4
解决办法
4万
查看次数

在WebException错误中获取错误号

如何在WebException错误中获取错误号?

try
{
     HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("site");
     HttpWebResponse response = (HttpWebResponse)request.GetResponse();
     Stream stream = response.GetResponseStream();
     int i = stream.ReadByte();
}
catch (WebException e)
{
     //How To Get Error number in WebException Error?
}
Run Code Online (Sandbox Code Playgroud)

c# webexception

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