Sunday, 15 February 2015

.net - C# User Controls: access controls properties -


I have created a control and added a textbox in that control, I can control that control on the .aspx page

< Pre> and lt;% @ register Src = "../ user control / account circuit." TagName = "SearchControl" tagfix = "CSR"%>

and

  & lt; Csr: SearchControl ID = "AccountSearchControlBox" runat = "server" OnSearchButtonClick = "RetreiveAccounts" />  

On the .aspx.cs file, I want to use the value of the textbox inside the user control ... How to get it?

Add a public property to AccountSearchControl.ascx

  Public string text box text {get {return TextBox1.Text; } Set {TextBox1.Text = value; }}  

By default, you have protected visibility in all the controls located on the page (take a look at AccountSearchControl.ascx.designed.cs to see), so you have to expose a method to access the text box of your page.


No comments:

Post a Comment