我有一个链接按钮。单击该链接按钮,我想要弹出一个对话框。我尝试了很多但无法继续。
以下是关于我如何尝试此操作的代码。
<。>在.cs文件中:(这是我动态创建链接按钮的方式)(我在jquery中使用了lnkButtons类。LinkButton lnkUpdateComment = new LinkButton();
lnkUpdateComment.ID = "" + objBridgeNotes.BridgeNotesId;
lnkUpdateComment.Text = "edit";
lnkUpdateComment.Attributes.Add("class", "lnkButtons");
lnkUpdateComment.Click += new EventHandler(lnkUpdateComment_Click);
.js文件:
$(document).ready(function() {
$(".lnkButtons").live("click", function() {
$("#divEditComment").dialog("option", "title", "Edit the Comment");
$("#divEditComment").dialog("open");
return true;
});
$(function () {
var dlg = $("#divEditComment").dialog({
autoOpen: false,
show: "blind",
hide: "blind",
//height: 450,
minWidth: 400,
//position: ['right', 210],
buttons: {
"Update Note": function () {
var Updates = btnSubmitComment.replace(/_/g, '$');
__doPostBack(Updates, '');
}
}
});
dlg.parent().appendTo(jQuery("form:first"));
});
});
<。>在.aspx文件中:
<div id="divEditComment">
<asp:UpdatePanel ID="updComments" runat="server">
<ContentTemplate>
<div>
<table width="100%" style="text-align: center">
<tr>
<td>
<div id="divComments" runat="server">
</div>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
答案 0 :(得分:0)
Jquery
$(function () {
var dlg = $("#divEditComment").dialog({
autoOpen: false,
show: "blind",
hide: "blind",
//height: 450,
minWidth: 400,
//position: ['right', 210],
buttons: {
"Update Note": function () {
var Updates = btnSubmitComment.replace(/_/g, '$');
__doPostBack(Updates, '');
}
}
});
dlg.parent().appendTo(jQuery("form:first"));
});
$(document).ready(function() {
$(".lnkButtons").live("click", function() {
$("#divEditComment").dialog("open");
return false;
});
});
<强>的.aspx 强>
<div id="divEditComment" title="Edit the comment">
<asp:UpdatePanel ID="updComments" runat="server">
<ContentTemplate>
<div>
<table width="100%" style="text-align: center">
<tr>
<td>
<div id="divComments" runat="server">
</div>
</td>
</tr>
</table>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
答案 1 :(得分:0)
只需将return true替换为false即可。它会奏效。
$(document).ready(function() {
$(".lnkButtons").live("click", function() {
$("#divEditComment").dialog("option", "title", "Edit the Comment");
$("#divEditComment").dialog("open");
**return false;**
});
$(function () {
var dlg = $("#divEditComment").dialog({
autoOpen: false,
show: "blind",
hide: "blind",
//height: 450,
minWidth: 400,
//position: ['right', 210],
buttons: {
"Update Note": function () {
var Updates = btnSubmitComment.replace(/_/g, '$');
__doPostBack(Updates, '');
}
}
});
dlg.parent().appendTo(jQuery("form:first"));
});
});
------------------- 更新 -------------------- -
LinkButton lnkUpdateComment = new LinkButton(); lnkUpdateComment.ID =&#34; MyBtn&#34; ; lnkUpdateComment.Text =&#34;我的名字是汗&#34 ;; lnkUpdateComment.Attributes.Add(&#34; class&#34;,&#34; lnkButtons&#34;); YourPlaceholder.Controls.Add(lnkUpdateComment); lnkUpdateComment.Click + = new EventHandler(lnkUpdateComment_Click);
$(".lnkButtons").live("click", function() {
var dlg33 = $("#dialog").dialog({
title: "Filter records",
height: "450",
width: "600",
maxHeight: "450",
maxWidth: "600",
buttons: {
"Update Note": function() {
var Updates = btnSubmitComment.replace(/_/g, '$');
__doPostBack(Updates, '');
}
}
});
dlg33.parent().appendTo(jQuery("form:first"));
return false;
});