FirstCode:
Copy code The Code is as follows: <Title> No title page </title>
<% -- <SCRIPT type = "text/JavaScript">
Function opendia (){
VaR returned = Window. showmodaldialog ("default4.aspx? "+ (New date (), window );
If (returned ){
Document. getelementbyid ("RET"). innerhtml = returned;
}
Else {
Document. getelementbyid ("RET"). innerhtml = "";
}
}
</SCRIPT> -- %>
<SCRIPT type = "text/JavaScript">
Function opendia (){
VaR returned = Window. showmodaldialog ("default3.aspx? "+ (New date (), window );
If (returned ){
Document. getelementbyid ("tbtext"). value = returned;
}
Else {
Document. getelementbyid ("tbtext"). value = "";
}
}
</SCRIPT>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div id = "RET">
<Input id = "tbtext" type = "text" value = "" onclick = "opendia (); Return false;"/>
</Div>
<Asp: button id = "button1" runat = "server" text = "button" onclientclick = "opendia (); Return false;"/>
<Input id = "hidden1" type = "hidden" runat = "server"/>
</Form>
</Body>
</Html>
New data () is used to avoid the automatic cache of the showmodaldialog page. As a result, the page is opened for the second time and the data is not refreshed, this is because the showmodaldialog page automatically displays the data in the cache if the URL is the same each time.
The code for defa3.3.aspx on the subpage is as follows: Copy code The Code is as follows: <Title> No title page </title>
<SCRIPT type = "text/JavaScript">
Function getselected (data ){
VaR STR = data;
Window. returnvalue = Str. tostring ();
Window. Close ();
}
</SCRIPT>
<Base target = "_ Self"/>
</Head>
<Body>
<Form ID = "form1" runat = "server" target = "">
<Div>
<Asp: gridview id = "gridview1" runat = "server" onrowdatabound = "gridview1_rowdatabound">
<Columns>
<Asp: templatefield>
<Itemtemplate>
<Asp: linkbutton id = "lnkselect2" runat = "server" text = "select"> </ASP: linkbutton>
</Itemtemplate>
</ASP: templatefield>
</Columns>
</ASP: gridview>
</Div>
</Form>
</Body>
</Html>
defa3.3.aspx has a gridview control. After the data is bound (the code is not pasted), select the data you need.
default3.aspx. CS:
[Code]
protected void gridview1_rowdatabound (Object sender, gridviewroweventargs e)
{< br> If (E. row. rowtype = datacontrolrowtype. datarow)
{< br> linkbutton B = (linkbutton) E. row. findcontrol ("lnkselect2");
B. attributes. add ("onclick", "javascript: getselected ('" + E. row. cells [1]. text + "');");
}< BR >}< br> [HTML]
In default3.aspx Arget = "_ Self"/> and
prevent the third form from being displayed after clicking the select button on the subpage.
in this example, we need to experience and improve it based on our own needs.