[英]JQuery Dialog box pop up through linkbuttons
I have a link button. 我有一个链接按钮。 On clicking on the that linkbutton, I want a dialog box to pop up.
在单击那个链接按钮时,我希望弹出一个对话框。 I tried a lot but unable to proceed.
我尝试了很多,但无法继续。
Following is the pieces of codes on how I am trying this. 以下是我如何尝试的代码片段。
in .cs file : (this is how I dynamically created the link button) (I have used lnkButtons class in my jquery. 在.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 file: .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"));
});
});
in .aspx file: 在.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>
Jquery 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 .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>
Just replace return true to return false. 只需替换return true即可返回false。 It will worked.
会的。
$(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"));
});
});
------------------- Update --------------------- ------------------- 更新 ---------------------
LinkButton lnkUpdateComment = new LinkButton(); LinkButton lnkUpdateComment =新的LinkButton(); lnkUpdateComment.ID = "MyBtn" ;
lnkUpdateComment.ID =“ MyBtn”; lnkUpdateComment.Text = "My name Is khan";
lnkUpdateComment.Text =“我的名字是可汗”; lnkUpdateComment.Attributes.Add("class", "lnkButtons");
lnkUpdateComment.Attributes.Add(“ class”,“ lnkButtons”); YourPlaceholder.Controls.Add(lnkUpdateComment);
YourPlaceholder.Controls.Add(lnkUpdateComment); lnkUpdateComment.Click += new EventHandler(lnkUpdateComment_Click);
lnkUpdateComment.Click + =新的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;
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.