(Original) How to interact in the user controls of the page and the page

xiaoxiao2021-03-06  42

Sometimes I want to call the user control of this page in the page, when I want to set the value of the control in the user control in the page, I am the solution first build a user control uc.ascx Place a label and set Its value is testthis.label1.text = "test"; joining a method in this user control PUBLIC VOID AA () {this.Label1.Text = "Method for calling this page in this page is successful"; Create a WebForm import this user control <% @ register tagprefix = "aa" tagname = "bb" src = "uc.ascx"%> <% @ register tagprefix = "aa" tagname = "bb" src = "uc.ascx "%> In the page contains page to add two button first button events ((UC) this.FindControl (" TOP ")). Label1.text =" Sets the value of the control in the user control "; // This Label1 is joined in the event of the Label second button in the user control ((UC) this.findControl (" TOP ")). AA (); The above two buttons are completed in the previous two operations. The UC is the class name of the UC for the user control (the name of the user control) if not in the same name control, and the name of the name control is added. <% @ Register tagprefix = "aa" tagname = "bb" src = "uc.ascx"%> <% @ register tagprefix = "aa" tagname = "bb" src = "uc.ascx"%> <% @ register Tagprefix = "aa" tagname = "bb" src = "uc.ascx"%> <% @ register tagprefix = "aa" tagname = "bb" src = "uc.ascx"%> <% @ register tagprefix = "aa "Tagname =" bb "src =" uc.ascx "%>

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

New Post(0)