(Forum Q & A Drop) How to operate another user control in a user control?

xiaoxiao2021-03-05  25

For example, a TOP user control is used to log in. The following buttom's user control is used to display the number of online people. If the login is required to refresh the online number of online people in ONLINE, you need to operate another user control in one user control. Control (these 2 user controls are included in a page)

Http://www.cnblogs.com/lovecherry/archive/2005/03/25/125515.html

with

Http://www.cnblogs.com/lovecherry/archive/2005/04/11/135543.html

People should know how to do it right away, in fact, the combination of 2. For example, 2 user controls WebUserControl1.ascx and WebUserControl2.ascx placed a lablic system.web.ui.webcontrols.label online) 2 User controls Drag and drop to the page, specify ID: The former places a button, the click event of the button is as follows: ((WebuserControl2) System.Web.httpContext.current.handler) .findControl ("Buttom")). Online.Text = "Has been updated"; // First is to lock this page (System.Web.ui.page) System.Web.httpContext.current.handler // Then lock from the page to this user control (WebuserControl2) ((System.Web.ui.page) System.Web.httpContext.current.handler ) .FindControl ("button" // Lastly locked from this user control to the control inside the user control ((WebuserControl2) ((System.Web.ui.page) System.Web.httpContext.current.Handler) .FindControl (" Buttom ")). Online Tested, press the button in the first user control, the Label of the second user control changes.

转载请注明原文地址:https://www.9cbs.com/read-37062.html

New Post(0)