C# 在jQuery模式窗口中显示代码隐藏中的数据
单击一个按钮,我就从asp.NETC中的代码隐藏打开了一个jQuery模式窗口# 以下是jquery:C# 在jQuery模式窗口中显示代码隐藏中的数据,c#,jquery,asp.net,modal-dialog,code-behind,C#,Jquery,Asp.net,Modal Dialog,Code Behind,单击一个按钮,我就从asp.NETC中的代码隐藏打开了一个jQuery模式窗口# 以下是jquery: <script type="text/javascript"> function showmodalpopup() { $("#popupdiv").dialog({ title: "Personal Information", width: 500, height: 450, modal: true,
<script type="text/javascript">
function showmodalpopup() {
$("#popupdiv").dialog({
title: "Personal Information",
width: 500,
height: 450,
modal: true,
buttons: {
Close: function () {
$(this).dialog('close');
}
}
});
};
我试图完成的是在模式窗口中显示从数据库中从代码隐藏获取的数据。
这里的联系信息是硬编码的。这只是一个例子
多谢各位
为模式代码中的每个值放置一个
标签,如下所示:
<div id="popupdiv" title="Basic modal dialog" style="display: none">
First Name: <asp:Label ID="lblFirstName" runat="server" Text=""></asp:Label><br />
Last Name: <asp:Label ID="lblLastName" runat="server" Text=""></asp:Label><br />
Agent No: <asp:Label ID="lblAgentNo" runat="server" Text=""></asp:Label><br />
Phone: <asp:Label ID="lblPhine" runat="server" Text=""></asp:Label><br />
Email: <asp:Label ID="lblEmail" runat="server" Text=""></asp:Label><br />
Address 1: <asp:Label ID="lblAddress1" runat="server" Text=""></asp:Label><br />
Address 2: <asp:Label ID="lblAddress2" runat="server" Text=""></asp:Label><br />
City: <asp:Label ID="lblCity" runat="server" Text=""></asp:Label><br />
State: <asp:Label ID="lblState" runat="server" Text=""></asp:Label><br />
Zip: <asp:Label ID="lblZip" runat="server" Text=""></asp:Label><br />
</div>
数据是否在文档(DOM)中?如果没有,那么打开模态将需要触发一个AJAX调用。如果是这样,那么打开你的模型需要使用合适的选择器来提取它。简短而简单!非常感谢。
<div id="popupdiv" title="Basic modal dialog" style="display: none">
First Name:<br />
Last Name:<br />
Agent No:<br />
Phone:<br />
Email:<br />
Address 1:<br />
Address 2:<br />
City:<br />
State:<br />
Zip:<br />
</div>
<asp:Button ID="btnShowModal" runat="server" Text="Contact Information" OnClick="btnShowModal_Click" /> <asp:Button ID="Messages" runat="server" Text="Inbox" OnClick="btnShowModal_Click" />
string lastName = tbl.Rows[0]["lastname"].ToString();
string fullName = tbl.Rows[0]["FullName"].ToString();
string Phone = tbl.Rows[0]["phone"].ToString();
string email = tbl.Rows[0]["email"].ToString();
string address1 = tbl.Rows[0]["address1"].ToString();
string address2 = tbl.Rows[0]["address2"].ToString();
string city = tbl.Rows[0]["city"].ToString();
string State = tbl.Rows[0]["State"].ToString();
string Zip = tbl.Rows[0]["Zip"].ToString();
<div id="popupdiv" title="Basic modal dialog" style="display: none">
First Name: <asp:Label ID="lblFirstName" runat="server" Text=""></asp:Label><br />
Last Name: <asp:Label ID="lblLastName" runat="server" Text=""></asp:Label><br />
Agent No: <asp:Label ID="lblAgentNo" runat="server" Text=""></asp:Label><br />
Phone: <asp:Label ID="lblPhine" runat="server" Text=""></asp:Label><br />
Email: <asp:Label ID="lblEmail" runat="server" Text=""></asp:Label><br />
Address 1: <asp:Label ID="lblAddress1" runat="server" Text=""></asp:Label><br />
Address 2: <asp:Label ID="lblAddress2" runat="server" Text=""></asp:Label><br />
City: <asp:Label ID="lblCity" runat="server" Text=""></asp:Label><br />
State: <asp:Label ID="lblState" runat="server" Text=""></asp:Label><br />
Zip: <asp:Label ID="lblZip" runat="server" Text=""></asp:Label><br />
</div>
protected void btnShowModal_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, GetType(), "Show Modal Popup", "showmodalpopup();", true);
string firstName = tbl.Rows[0]["firstName"].ToString();
string lastName = tbl.Rows[0]["lastName"].ToString();
//
//
// and so on
lblFirstName.Text = firstName;
lblLastName.Text = lastName;
//
//
// and so on
}