我在下面使用此代码,其操作正常但在使用MasterPage时,其行为存在严重问题,代码无法正常运行。
/// script /////
$(".cssopen").click(function (e) {
//Cancel the link behavior
e.preventDefault();
//Get the A tag
//var id = $(this).attr('href');
//alterado
var id = '.window';
var body = $("html");
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set height and width to mask to fill up the whole screen
$('#mask').css({ 'width': maskWidth, 'height': maskHeight });
//transition effect
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow", 0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH / 2 - $(id).height() / 2);
$(id).css('left', winW / 2 - $(id).width() / 2);
//inserido
href = $(this).attr("href");
$('.window').load(href);
//transition effect
$(id).fadeIn(2000);
//$(id).show();
$(id).show().position({ my: "center", at: "center", of: "html" });
});
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask, .window').hide();
});
//if mask is clicked
$('#mask').click(function () {
$(this).hide();
$('.window').hide();
});
/////////////// code .aspx //////////////////
<div>
<asp:ImageButton ID="imgBtCmd" runat="server" ImageUrl="~/Image/edit.png" href="frmIndexII.aspx" CssClass="cssopen"/>
</div>
答案 0 :(得分:-1)
我不确定你是否发布了所需的所有信息,但我正在做出有根据的猜测,你正在使用jQuery抓取ID控件,并且自引入母版页以来已经破了。这是因为母版页将更改呈现的HTML元素的客户端ID。
如果您使用.net4及以上版本,则可以使用
<asp:SomeControl ClientIdMode="static">
控件将保留其Id客户端。或者,您可以向控件添加一个类,并按类而不是ID来jQuery。