因为在showModalDialog中的超链和回发都会弹出自己本身的窗体,所以加个IFRAME页面:TextBoxSelectDialogDefaultFrame.aspx
无后台代码
<iframe name="mainIFrame" id="mainIFrame" height="490px" width="100%" border="0" frameborder="0">
</iframe>
<script type="text/jscript">
var p = window.dialogArguments;
$("#mainIFrame").attr("src", p.url);
</script>
IFRAME里装载的才是真正的弹出窗页面:
<asp:Panel runat="server" ID="panelSearch">
<table cellspacing="1" align="center" class="Table">
<tr>
<td width="10%" class="TDTitle">
搜索关键字:
</td>
<td width="20%" class="TDCtrl">
<asp:TextBox ID="txtKeyWord" CssClass="textbox" runat="server"></asp:TextBox>
</td>
<td class="TDNote">
<asp:Label runat="server" ID="lbDescription" Text="解释"></asp:Label>
</td>
</tr>
<tr>
<td class="TDCtrl" style="padding: 5px 0px 5px 10px;" colspan="3">
<asp:Button ID="btnSearch" runat="server" CssClass="button" Text="查询" OnClick="btnSearch_Click" />
</td>
</tr>
</table>
</asp:Panel>
<br />
<asp:GridView runat="server" ID="GridView1" AllowPaging="false" AutoGenerateColumns="false"
Width="99%" BorderWidth="0" CellPadding="0" CellSpacing="1" BackColor="#c0de98"
HorizontalAlign="Center" OnRowDataBound="GridView1_RowDataBound">
</asp:GridView>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="bottom" height="30px">
<div style="width: 95%;" class="STYLE1">
<webdiyer:AspNetPager CssClass="aspnetpager" ID="AspNetPager1" HorizontalAlign="Right"
OnPageChanging="AspNetPager1_PageChanging" runat="server" ShowPageIndex="false"
ShowPageIndexBox="Always" SubmitButtonImageUrl="../Resources/Images/AspNetPager/go.gif"
AlwaysShow="true" ImagePath="../Resources/Images/AspNetPager/" ButtonImageNameExtension="n"
ButtonImageExtension=".gif" DisabledButtonImageNameExtension="g" CpiButtonImageNameExtension="r"
PagingButtonType="Image" PageIndexBoxClass="indexbox" CustomInfoHTML="共%RecordCount%条纪录,当前第%CurrentPageIndex%/%PageCount%页,每页%PageSize%条记录"
ShowCustomInfoSection="Left" CustomInfoTextAlign="Left">
</webdiyer:AspNetPager>
</div>
</td>
</tr>
</table>
<script type="text/jscript">
var selectedRow;
function SelectRow(id) {
var tbl = $(id)[0];
if (tbl) {
for (var i = 1; i < tbl.rows.length; i++) {
tbl.rows[i].onmouseover = function () {
if (this != selectedRow) {
for (var j = 0; j < this.cells.length; j++) {
this.cells[j].style.backgroundColor = "#EDF1E8";
}
}
}
tbl.rows[i].onmouseout = function () {
if (this != selectedRow) {
for (var j = 0; j < this.cells.length; j++) {
this.cells[j].style.backgroundColor = "#FFFFFF";
}
}
}
tbl.rows[i].onclick = function () {
if (selectedRow) {
for (var j = 0; j < selectedRow.cells.length; j++) {
selectedRow.cells[j].style.backgroundColor = "#FFFFFF";
}
}
for (var j = 0; j < this.cells.length; j++) {
this.cells[j].style.backgroundColor = "#86A752";
}
selectedRow = this;
}
tbl.rows[i].ondblclick = function () {
var fields = "<%=xmlModel.ValueTextFields %>";
if (window.parent.p.setValueControlFieldList != "") {
fields = fields + ',' + window.parent.p.setValueControlFieldList;
}
var fieldArray = fields.split(',');
var idPre = "<%=GridView1.ClientID %>_";
var resArray = new Array();
for (var i = 0; i < fieldArray.length; i++) {
for (var j = 0; j < this.cells.length; j++) {
if (idPre + fieldArray[i] == tbl.rows[0].cells[j].id) {
resArray.push(i.toString() + ":\"" + this.cells[j].innerText + "\"");
break;
}
if (j == this.cells.length - 1) {
alert("The field of " + fieldArray[i] + " was not found!");
return;
}
}
}
window.parent.returnValue = eval('({' + resArray.join(',') + '})');
window.parent.returnValue.length = resArray.length;
// debugger;
window.parent.close();
}
}
}
}
$(document).ready(function () {
SelectRow("#<%=GridView1.ClientID %>");
});
</script>
玩技术,要学会忍受寂寞--