jQuery的触发asp.net单选按钮点击更新面板内 [英] jQuery trigger asp.net radiobutton click inside of update panel

查看:150
本文介绍了jQuery的触发asp.net单选按钮点击更新面板内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些code,其中用户选择一个一揽子这是通过jQuery高亮显示。我怎么可能会导致在此ASP单选按钮的div被点击并执行其'OnCheckChanged'事件?

I have some code where the user selects a 'Package' which is highlighted via jquery. How can i cause the asp radiobutton in this div to be clicked and perform its `OnCheckChanged' event?

$(document).ready(function () {
        $(".package-container").click(function (event) {
            $(this).closest('.radio-group-row').find('.package-title').removeClass('highlight');
            $(this).closest('.radio-group-row').find('.package-footer').removeClass('highlight');
            $(this).find('input:radio').prop('checked', true).click();
            $(this).find('.package-title').addClass('highlight');
            $(this).find('.package-footer').addClass('highlight');
        });
    });

我曾尝试使用的onclick()方法,此code,但它会不断加载页面的网络选项卡内的镀铬中不断发布的网页,并最终滞后了没有刷新。

I have tried this code using the onclick() method but it continually loads the page inside of the network tab in chrome is keeps posting the page and eventually lags out without a refresh.

我的问题单选按钮是这样的:

My radiobutton in question is this:

<EclipseUI:CustomRadioButton runat="server" ID="RadioButton_Item" ClientIDMode="AutoID" ToolTip='<%# Eval("SystemValue") %>' GroupName="Package" OnCheckedChanged="RadioButton_Package_OnCheckedChanged" AutoPostBack="True"/>

我怎样才能让jQuery的执行此单选按钮的oncheckedchange事件?

How can i make jquery perform the oncheckedchange event of this radiobutton?

修改

$(document).ready(function () {
        $(".package-container").click(function (event) {
            $(this).closest('.radio-group-row').find('.package-title').removeClass('highlight');
            $(this).closest('.radio-group-row').find('.package-footer').removeClass('highlight');
            $(this).find('input:radio').prop('checked', true).click();
            $(this).find('.package-title').addClass('highlight');
            $(this).find('.package-footer').addClass('highlight');
        });
    });



    var prm = Sys.WebForms.PageRequestManager.getInstance();

    prm.add_endRequest(function (event) {
        var currPackage = $("#HF_Package").val();

        $("#" + currPackage).closest('.radio-group-row').find('.package-title').removeClass('highlight');
        $("#" + currPackage).closest('.radio-group-row').find('.package-footer').removeClass('highlight');
        $("#" + currPackage).find('input:radio').prop('checked', true);
        $("#" + currPackage).find('.package-title').addClass('highlight');
        $("#" + currPackage).find('.package-footer').addClass('highlight');
    });

我的全jQuery的code看起来是这样的。后半部分是确保其所选软件包的回传被选中,我从一个隐藏字段与此值,找到这个价值是封装的DIV。

My full jquery code looks like this. The latter part is for the postback to ensure their selected package is highlighted, i get this value from a hidden field and find the div of this value which is the package.

推荐答案

在更新面板的DOM元素被替换为内容来自异步回发回这样的事件绑定复位。

in update panel your DOM elements are replaced with content returned from async postback so event binding is reset.

您需要连接2事件事件处理程序:

you need to attach event handlers on 2 events :

(function($){ 

  var bindEvents =  function(){
   // bind events here;
  };

  // initial load
  $(document).ready( bindEvents);

  // every async load by update panel
  Sys.WebForms.PageRequestManager.getInstance().add_endRequest(bindEvents);

})(jQuery);  

触发回传,尝试添加按钮(你可以用CSS(DISPLY隐藏:无),如果你不显示它),然后添加按钮的UpdatePanel异步触发和呼叫
_doPostBack并通过该按钮标识

for triggering postback, try adding button (you can hide it with css (disply:none) if you don't to display it) then add that button as updatepanel async trigger and call _dopostback and pass that button id

__doPostBack('<%= TheButton.ClientID %>', '');

这篇关于jQuery的触发asp.net单选按钮点击更新面板内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆