jQuery加载后的ASP.Net Postback

时间:2014-12-11 16:35:19

标签: jquery asp.net postback

当用户点击按钮时,我正在将一个单独的URL加载到我页面上的DIV中。发生这种情况时,下次我的页面需要回发时,回发将转到我在DIV中加载的单独URL。

为什么会发生这种情况,如何阻止它回发到其他页面?

以下是步骤:

  1. 用户加载主页
  2. 用户单击按钮以调用jQuery加载方法以从单独的URL加载HTML
  3. 用户在主页上导致回发
  4. 该页面将回发到单独页面的URL而不是主页
  5. 一些示例代码:

    当用户点击按钮

    $('#anchorViewResourceCalendar').unbind('click');
    $('#anchorViewResourceCalendar').click(function (e) {
        e.preventDefault();
        var webUserID = $('select.ddlResource').val();
        var date = $('select.ddlMonth').val();
        if (webUserID > 0) {
            var calendarContainer = $('#divResourceCalendarContentContainer');
            calendarContainer.html('<div>Please wait...</div>');
            $('#divResourceCalendarContainer').dialog('open');
    
            calendarContainer.load('../ViewUserCalendar.aspx?ViewWebUserID=' + webUserID + '&Date=' + date);
        }
    });
    
    // Code for when the dialog opens/closes (since I'm emptying out the containing div)
    $('#divResourceCalendarContainer').dialog({
        autoOpen: false,
        width: '1050',
        height: '850',
        modal: true,
        open: function () {
            $(this).parent().appendTo(jQuery("form:first"));
    
            $('.ui-widget-overlay').bind('click', function () {
                $('#divResourceCalendarContainer').dialog('close');
            })
        },
        close: function () {
            $('#divResourceCalendarContentContainer').empty(); // this removes anything added by jQuery on the page so it's back to it's original state of when the page was initially loaded
        }
    });
    

0 个答案:

没有答案