本想贴一些效果图出来,但是可能涉及到所在公司的保密性问题,删去
===============================================================
The First Page:
//Notice the id of control , because the control is not the standard control of HTML, the builder will give another for it when buiding, e.g ctl00_newContentPlaceHolder_emailtext, we can find it in the souce of page when explored...
<script language=javascript>
function dialog()
{
var nameToFind = aspnetForm.document.getElementById("ctl00_newContentPlaceHolder_textBox1").value;
//alert(nameToFind);
var result = window.showModalDialog("SCDList.aspx?nameToFind="+nameToFind+"","Dialog Arguments Value","dialogHeight: 300px; dialogWidth: 580px; dialogTop: 108px; dialogLeft: 514px; edge: Raised; center: Yes; help: Yes; resizable: No; status: Yes;");
var arrayresult = result.split('+');
aspnetForm.document.getElementById("ctl00_newContentPlaceHolder_emailtext").value = arrayresult[2];
aspnetForm.document.getElementById("ctl00_newContentPlaceHolder_grouptext").value = arrayresult[3];
}
</script>
//..............anything else
// To Call the JS function dialog()...
<td style="width: 295px; height: 25px;" align="left">
<input type=text id="textBox1" runat=server style="width: 150px"/>
<button id="Botton1" οnclick="dialog()" >SCD...</button></td>
=================================================================
The Second Page:
//经过查询,可以动态生成网页,如果有需要,可以用JS取到这些动态网页上的值,然后返回结果给第一张页面
//这是后台的代码
protected void Page_Load(object sender, EventArgs e)
{
NameToFind = Convert.ToString(Request.QueryString["nameToFind"]);
ArrayList list = scd.ExeLdap(NameToFind);
int i = list.Count;
Log4netWrapper.log.Debug("NameCount:" + i.ToString());
// Judge whether the information is in the SCD database...
Response.Write(@"<HTML><HEAD><link rel='stylesheet' type='text/css' media='screen,projection' href='css/grid.css' />
<link rel='stylesheet' type='text/css' media='screen,projection' href='css/styles.css' /></HEAD><BODY>");
Response.Write(@"<div class='portlet'>");
Response.Write(@"<h3>SCD Search Result</h3>");
if (i > 0)
{
// Write the dynamic HTML page...
Response.Write("<H4>Please choose your information:</H4>");
Response.Write(@"<table >");
// Response.Write(@"<tr><td>Please choose your information</td></tr>");
Response.Write(@"<tr>");
Response.Write(@"<td >Firstname</td>");
Response.Write(@"<td >Lastname</td>");
Response.Write(@"<td >Email</td>");
Response.Write(@"<td >Company</td>");
Response.Write(@"</tr>");
// Output every query list as rows...
for (int index = 0; index < i; index++)
{
ScdResult result = new ScdResult();
result = (ScdResult)(list[index]);
// Get the each attribute from the ScfResult class...
string firstname = result.GetFirstName();
string lastname = result.GetLastName();
string company = result.GetCompany();
string email = result.GetEmail();
// Create the new row with different ID...
Response.Write(@"<tr id='tr" + index + "' οnclick='result(" + index + ")'>");
Response.Write(@"<td width='15%' id='tr" + index + "td2'>" + firstname + @"</td>");
Response.Write(@"<td width='15%' id='tr" + index + "td3'>" + lastname + @"</td>");
Response.Write(@"<td width='50%' id='tr" + index + "td4'>" + email + @"</td>");
Response.Write(@"<td width='20%' id='tr" + index + "td5'>" + company + @"</td>");
Response.Write(@"</tr>");
}
Response.Write(@"</table>");
}
// If no information is in the query result...
else
{
// Write the dynamic HTML page...
Response.Write("<table><tr><td>Sorry! We can't find your information in our SCD database</td></tr>");
Response.Write("<tr><td>You can try it again</td></tr>");
Response.Write("<tr><td>");
Response.Write("<button οnclick='error()'>Close the window.</button>");
Response.Write("</td></tr>");
Response.Write("</table>");
}
Response.Write(@"</DIV>");
Response.Write(@"</BODY></HTML>");
}
//前台代码
//该函数触发源是<tr></tr>的onclick()动作
<script>
function result(index)
{
//var num =get(this);
//var num =form1.document.getElementById(get(this)).id;
var firstname = form1.document.getElementById("tr" + index + "td2").innerText;
var lastname = form1.document.getElementById("tr" + index + "td3").innerText;
var email= form1.document.getElementById("tr" + index + "td4").innerText;
var company = form1.document.getElementById("tr" + index + "td5").innerText;
//var result = firstname+lastname+email+company;
var result = firstname+"+"+lastname+"+"+email+"+"+company;
window.returnValue=result;
window.close();
}
function error()
{
window.close();
}
</script>