SoFunction
Updated on 2025-03-01

JavaScript pop-up form click the button to return to the implementation of selecting data

First is the code of the parent page:
Copy the codeThe code is as follows:

<head runat="server">
<title>Unt title page</title>
<%-- <script type="text/javascript">
function openDia() {
var returned = ("?" + (new Date()), window);
if (returned) {
("ret").innerHTML = returned;
}
else {
("ret").innerHTML = "";
}
}
</script> --%>
<script type="text/javascript">
function openDia(){
var returned = ("?" + (new Date()), window);
if (returned){
("tbtext").value = returned;
}
else{
("tbtext").value = "";
}
}
</script>
</head>
<body>
<form runat="server">
<div >
<input type="text" value="" onclick="openDia();return false;" />
</div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="openDia();return false;" />
<input type="hidden" runat="server" />
</form>
</body>
</html>

Regarding adding (new Data()) is to avoid the problem of automatic cache of showModalDialog page, which causes the second time the page is opened and the data is not refreshed. This is because if the URL of the showModalDialog page is the same every time, it will automatically display the data in the cache.
Next is the code for the subpage:
Copy the codeThe code is as follows:

<head runat="server">
<title>Unt title page</title>
<script type="text/javascript">
function getSelected(data) {
var str = data;
= ();
();
}
</script>
<base target="_self"/>
</head>
<body>
<form runat="server" target="">
<div>
<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton runat="server" Text="Select" > </asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
&nbsp;</div>
</form>
</body>
</html>

There is a gridview control inside. After data binding (bind it yourself, the code will not be posted). After that, you will choose the data you need.
:
[code]
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if ( == )
{
LinkButton b = (LinkButton)("lnkSelect2");
("OnClick", "javascript:getSelected('" + [1].Text + "');");
}
}
[html]
The function of the <head></head> and <form target=""> between the <head></head> is to prevent the third form from popping up after clicking the selection button on the subpage.
This is the case. Specifically, you need to experience and improve according to your own needs.