Because the user control will be parsed before the home control ..
Therefore, the control on the home page cannot be captured in the user control event (for example, <asp: textbox id = "txtbillno"/>, because it has not been resolved ).
You can solve this problem by using the following methods:
Register a hidden control in the "add" event of the user control:
Private Void Imgbtnadd_click ( Object Sender, system. Web. UI. imageclickeventargs E)
{
This . Page. registerhiddenfield ( " Isopenaddpage " , " True " );
}
Then write at the bottom of the Home Page: </ Tr >
</ Table >
</ Form >
< Script Language = "JavaScript" >
VaR OBJ = Document. getelementbyid ( " Isopenaddpage " );
If (OBJ ! = Null )
{
If (Obj. Value = ' True ')
{
Openaddpage ();
OBJ. Value = '';
}
}
Function Openaddpage ()
{
VaR Sid = Document. getelementbyid ('txtbillno'). value;
VaR URL = '.. / Cangkull / Cangkulladd. aspx ? Returncontrol = Ccdatagrid1_imgbtnadd & Strbillno = ' + Sid;
Window. Open (URL, 'new _ 1', 'left = 160 , Top = 200 , Height = 450 , Width = 750 , Toolbar = 0 , Scrollbars = 2 ');
}
</ Script >
</ Body >
</ Html >
In this way, you can access the controls on the home page in the "add" event of the user control!
(The "add" event of the user control refreshes the homepage, so the above script is re-executed)