Ajax控件工具包评级控制 - 覆盖RatingBehavior.js

时间:2009-02-10 04:39:14

标签: asp.net javascript ajax

ajax控件工具包中的评级控件不会引发事件,如果用户点击当前评级星因为它检查的行为js if(this._ratingValue!= this._currentRating),所以我想覆盖这个方法而不改变js和构建takeit。我该怎么做,可以扩展评级控制并覆盖RatingBehavior.js或任何其他解决方案。

_onStarClick : function(e) {
        /// <summary>
        /// Handler for a star's click event
        /// </summary>
        /// <param name="e" type="Sys.UI.DomEvent">
        /// Event info
        /// </param>
        if (this._readOnly) {
            return;
        }
        if (this._ratingValue != this._currentRating) {
            this.set_Rating(this._currentRating);
        }
    },

1 个答案:

答案 0 :(得分:3)

我已经通过将代码放在上面

解决了这个问题

    function AddNewRatingHandler() {

        AjaxControlToolkit.RatingBehavior.prototype._onStarClick =
            function(e) {
                if (this._readOnly) {
                    return;
                }
                //   if (this._ratingValue != this._currentRating) {                    
                this.set_Rating(this._currentRating);
                // }
            };
            AjaxControlToolkit.RatingBehavior.prototype.set_Rating = function(value) {                    
                //   if (this._ratingValue != value) {
                this._ratingValue = value;
                this._currentRating = value;
                if (this.get_isInitialized()) {
                    if ((value < 0) || (value > this._maxRatingValue)) {
                        return;
                    }

                    this._update();

                    AjaxControlToolkit.RatingBehavior.callBaseMethod(this, 'set_ClientState', [this._ratingValue]);
                    this.raisePropertyChanged('Rating');
                    this.raiseRated(this._currentRating);
                    this._waitingMode(true);

                    var args = this._currentRating + ";" + this._tag;
                    var id = this._callbackID;

                    if (this._autoPostBack) {
                        __doPostBack(id, args);
                    }
                    else {
                        WebForm_DoCallback(id, args, this._receiveServerData, this, this._onError, true)
                    }

                }
                //  }
            };                
    }
    AddNewRatingHandler();

</script>



</div>

</form>