1


我有一个这样的网络方法

    
    [WebMethod]
    public static string UpdateProduct(Products obj)
    {
        DbTools.runcmd(TSQLCreate.Update(obj));
        return "SUCCESS";
    }
    

并有一个用 JS 创建的 XHR 请求,用于将 obj 传递给湿方法

    
    SendOBJToMethod("some.aspx/UpdateProduct"
    ,obj // My Product Object
    ,function() { alert("Updated"); }); //SUCCESS FUNC
    

和产品类是这样的

    
    public class Products : Books
    {
        public Products()
        {
            this.AddedDate = DateTime.Now;
            ///throw new NotImplementedException();
        }

        #region COMMON
        [SQLIDColumn]
        public int ProductID { get; set; }
        [SQLColumn]
        public string ProductName { get; set; }
        [SQLColumn]
        public string ProductCode { get; set; }
        [SQLColumn]
        public string Barcode { get; set; }
        ..............
        private bool isOnePrice;
        [SQLColumn]
        public bool IsOnePrice
        {
            get { return isOnePrice; }
            set { isOnePrice = value; }
        }

        private decimal onePrice;
        [SQLColumn]
        public decimal OnePrice
        {
            get
            {
                if (onePrice == 0M) onePrice = labelPrice;
                return onePrice;
            }
            set {onePrice = value;}
        }
    }
    

问题:
当我将对象(产品)作为属性(十进制)发送时,OnePrice 为空,我收到错误“不是十进制的有效值”。

让我知道这一点,谁抛出的异常?因为我想更改此消息。

谢谢。

4

0 回答 0