日期:2014-05-17  浏览次数:20501 次

onclick不起作用了,求解
C# code

//原本的代码(onclick没有问题):
<A:ButtonEx ID="btnAdvancedSearch_Up" runat="server" Text="预览结果" OnClick="btnAdvancedSearch_Click"/>
<A:ButtonEx ID="btnCancel_Up" runat="server" Text="取消" OnClick="btnCancel_Click"/>
//修改后的代码
<Anshu:ButtonEx ID="btnAdvancedSave_Up" runat="server" Text="保存检索条件到个人数据分类"/>
<A:ButtonEx ID="btnAdvancedSearch_Up" runat="server" Text="预览结果" OnClick="btnAdvancedSearch_Click"/>
<A:ButtonEx ID="btnCancel_Up" runat="server" Text="取消" OnClick="btnCancel_Click"/>

//添加代码:
<A:PopupPanelControl ID="FilterPopupPanel" runat="server" Width="400" Height="100" Caption="分类">
<A:ButtonEx ID="btnCategoryOk" runat="server" Text="确定" CausesValidation="false" CommandName="OK" OnClientClick="if(!onSave()) return false;" OnClick="btnCategoryOk_Click"/>
<A:ButtonEx ID="btnCategoryCancel" runat="server" Text="取消" CausesValidation="false" CommandName="Cancel" OnClick="btnCategoryCancel_Click"/>
<asp:HiddenField ID="hd_IsHide" runat="server" />
</A:PopupPanelControl>
<script type="text/javascript">
        //初始化
        $(document).ready(function () {
            reload();   
            var isHide = $('<%=hd_IsHide.ClientID %>').val();
            if (isHide == null ||  isHide == "hide"){
                HideFilterPopupPanel();
            }
            else{
                ShowFilterPopupPanel();
            }
        });
        function reload() {
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        }
        function EndRequestHandler() {
            var isHide = $('<%=hd_IsHide.ClientID %>').val();
            if (isHide == null  ||  isHide == "hide"){
                HideFilterPopupPanel();
            }
            else{
                ShowFilterPopupPanel();
            }
        }
        function HideFilterPopupPanel(){
           <%=FilterPopupPanel.ClientID%>.Hide();
        }
        function ShowFilterPopupPanel(){
            <%=FilterPopupPanel.ClientID%>.Show();
        }
        function onSave() {
            var categoryName = <%=txtCategoryName.ClientID %>.GetValue();;
            options = {
                type: "POST",
                url: "……",
                contentType: "application/json;charset=utf-8",
                dataType: "json",
                async: false
            };
            returnText = $.ajax(options).responseText;
        }
</script>

//aspx.cs页面:onLoad方法添加:
btnAdvancedSave_Up.OnClientClick = string.Format("ShowFilterPopupPanel();return false;", FilterPopupPanel.ClientID);


是不是因为弹出的这个PopupPanelControl,或者是因为我在添加的那个buttom用了Ajax?..
求解以及解决方法……

------解决方案--------------------
看不到问题所在,帮顶....
------解决方案--------------------
看不到问题所在
------解决方案--------------------
试试 是不是跟页面加载元素顺序有关
------解决方案--------------------
onclientclick


在不行的话,直接在后台注册一个js事件:

C# code

btndisply.Attributes.Add("onclick", "javascript:return bntAddClick();");