1. Purpose:
The page contains a buttn named btnnew. It will pop up a page for new content.
The page contains a gridview used to display data. The last two columns of the gridview are "detail" and "delete ".
Btnnew is required to pop up a new window for adding data.
A new window is displayed in the "details" column of gidview to view data.
The delete column in gidview is used to delete the data of the current row.
Now the problem is coming.
Problem 1: The response. Redirect method cannot open a new window.
Question 2: If the target = '_ blank' attribute in form is used, a new window is displayed when you click Delete in the gridview.
Question 3: If you change "delete" to <a href = 'xxx. aspx 'target = '_ blank'> Delete </a>. Unable to call future generations Code Unless Ajax is used.
Problem 4: Use the JS window. open () method. When "window. opener. Location. href = Window. opener. Location. href" is used to refresh the parent window, the data in the gridview cannot be refreshed. When "window. opener. location. reload (); "when refreshing the parent window, each refresh will pop up a dialog box for sending a message again, asking you to confirm and resend the message to refresh the page (the latter method was tested by netizens ).
2. solution:
1、when you single-click btnnewexample, let form.tar get = '_ blank', so that all links will open in a new window.
2XX When deleting a single statement, let form.tar get = '_ Self' first '. In this way, no new window will pop up.
3. The Code is as follows:
1) single-click btnnewto make form.tar get = '_ blank '. This method is put in the load event.
Protected Void Page_load ( Object Sender, eventargs E)
{
Try
{
If ( ! Ispostback)
{
Btnnew. Attributes. Add ( " Onclick " , " Form.tar get = '_ blank' " );
}
}
Catch (Exception error)
{
}
}
2nd, before deleting, let the form.tar get = '_ Self' code first: this event is placed in the rowdatabound event of the gridview. Code:
Protected Void Gvwlist_rowdatabound ( Object Sender, gridviewroweventargs E)
{
// Hide key
E. Row. cells [ 0 ]. Visible = False ;
// The pop-up window is not displayed, and Deletion prompt.
E. Row. cells [E. Row. cells. Count - 1 ]. Attributes [ " Onclick " ] = " Document.forms1_02.16.tar get = '_ Self'; return confirm ('Are you sure you want to delete it? '); " ;
}