Solve the problem that the user control calls the home control.

Source: Internet
Author: User
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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.