小编Sud*_*lam的帖子

在C#中测试数组的相等性

我有两个数组.例如:

int[] Array1 = new[] {1, 2, 3, 4, 5, 6, 7, 8, 9};
int[] Array2 = new[] {9, 1, 4, 5, 2, 3, 6, 7, 8};
Run Code Online (Sandbox Code Playgroud)

确定它们是否具有相同元素的最佳方法是什么?

c# arrays

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

从客户端SIde上的ASP.NET PageMethods获取异常详细信息

我有一个页面方法,我从我的JavaScript中打电话说

Pagemethods.MyMethod(MyParameter, onsucess, onfailure);
Run Code Online (Sandbox Code Playgroud)

在守则背后,我有这样的事情:

[WebMethod]
public static void MyMethod(Param)
{
   try{
     //DoSomething..
   }
   catch(exception ex)
   {
      //Log the exception and rethrow
      throw new exception(ex.innerexception);
   }
}
Run Code Online (Sandbox Code Playgroud)

现在我面临的问题是:

每当我得到异常时,我都会从代码中抛出异常

但是在onfailure方法中,我只是得到一条通用消息,说"服务器方法MyMethod失败并出现以下错误:"

我似乎没有得到异常细节,只有那个通用异常,

我如何获得JavaScript的异常细节,以便根据UI/JavaScript方面处理它.

我已经验证,这不是web.config中自定义错误设置的问题.

有人可以告诉我这里发生了什么吗?

PS:我已经逐步完成了每一行代码,并且在记录之后异常重新抛出了正确的异常细节,即消息.

web-services exception asp.net-ajax asmx pagemethods

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

带有单个文本字段的HTML表单+阻止Internet Explorer中的回发

我注意到IE中有一个相当奇怪的行为.

我有一个带有单个输入文本字段和提交按钮的HTML表单

在提交单击时,我需要执行一个必要的客户端JavaScript函数.

现在当我想阻止文本字段中的回发时(在输入键上按下)

我添加了一个按键式JavaScript函数,如下所示:


<input type=text onkeypress="return OnEnterKeyPress(event)" />

 function OnEnterKeyPress(event) {
            var keyNum = 0;
            if (window.event) // IE
            {
                keyNum = event.keyCode;
            }
            else if (event.which) // Netscape/Firefox/Opera
            {
                keyNum = event.which;
            }
            else return true;  
            if (keyNum == 13) // Enter Key pressed, then start search, else do nothing.
            {
                OnButtonClick();
                return false;
            }
            else
                return true;
        }
Run Code Online (Sandbox Code Playgroud)

扼杀这不起作用.


但是如果我将文本字段传递给函数:

<input type=text onkeypress="return OnEnterKeyPress(this,event);" />

 function OnEnterKeyPress(thisForm,event) {
            var keyNum = 0;
            if (window.event) // IE …
Run Code Online (Sandbox Code Playgroud)

javascript internet-explorer autopostback javascript-events

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

为什么这个通用的接口定义错了?

我正在尝试编写一个看起来像这样的界面

public interface IPropertyGroupCollection
{
    IEnumerable<IPropertyGroup> _Propertygroups { get;}
}

public interface IPropertyGroup
{
    IEnumerable<IProperty<T, U, V>> _conditions { get; }
}

public interface IProperty<T, U, V>
{
    T _p1 { get; }
    U _p2 { get; }
    V _p3 { get; }
}

public class Property<T, U, V> : IProperty<T, U, V>
{
    //Some Implementation
}
Run Code Online (Sandbox Code Playgroud)

我继续为_Conditions的可枚举定义获取编译错误.

我究竟做错了什么?Idea是实现类将提供通用属性包集合

c# generics interface generic-programming

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