OnClick和OnClientClick不能在RadButton中一起工作

时间:2014-11-17 11:48:33

标签: onclick onclientclick

IN RadButton OnClick事件和OnClient事件不能一起工作。 OnClient不会调用Javascript单击radbutton。我也使用RadAjaxSetting。

<script language="javascript" type="text/javascript">
         form_dirty = false;
         calenderclink = false;
         window.onbeforeunload = askUser;
         function setSaveEnable() {
             document.getElementById('ctl00_ContentPlaceHolder1_btnSave_85').disabled = false;
             form_dirty = true;
             calenderclink = false;
         }
         function form_dirty_true() {
             document.getElementById('ctl00_ContentPlaceHolder1_btnSave_85').disabled = false;
             form_dirty = true;
             calenderclink = false;
         }
         function form_dirty_false() {
             form_dirty = false;
             calenderclink = false;
             Calnederdirty = false;
         }
         function setSaveEnableforCalender() {
             form_dirty = true;
             calenderclink = true;
         }
         function askUser(evt) {
             var vtxtSiv = '<%=HndDiscurdMessage.ClientID%>';
             var message = document.getElementById(vtxtSiv).value;
             if (form_dirty == true && calenderclink == false) {
                 if (typeof evt == 'undefined') {
                     evt = window.event;
                 }
                 if (evt) {
                     evt.returnValue = message;
                 }
                 return message;
             }
             else if (form_dirty == true && calenderclink == true) {
                 if (document.getElementById('ctl00_ContentPlaceHolder1_rdpWishDate').value != null) {
                     form_dirty = true;
                     calenderclink = true;
                 }
             }
         }

         function ClearAlert() {
             var _dvAlert = document.getElementById("<%# dvAlert.ClientID %>");
             _dvAlert.attributes[2].value = "display: none;";
             form_dirty_true();
         }
    </script>


<telerik:RadButton ID="btnSave_85" runat="server" CssClass="btnMain btngreen right topRightBtn" OnClientClick="form_dirty_false();" SingleClick="true"
            Text="Save" OnClick="btnSave_Click" ></telerik:RadButton>

ONClick工作正常但在clientclick上无效。

1 个答案:

答案 0 :(得分:0)

试试这个。

<telerik:RadButton ID="btnSave_85" runat="server" CssClass="btnMain btngreen right topRightBtn" OnClientClick="form_dirty_false;" SingleClick="true"
        Text="Save" OnClick="btnSave_Click" ></telerik:RadButton>

然后在你的javascript中有这个:

function form_dirty_false(s,a) {
   form_dirty_false(); // your original code
}