User Controls

appancaft

New Member
Newbe Question:<BR> Is it possible to have few <asp:TextBox> fields in the (asp.net)aspx and retrieve them from an (user control)ascx file? If so, how do I reference the <asp:TextBox> controls from the user control file?try to make reference to those <asp:textbox> from control and initialize them. after that you alway can do something with them.<BR>think it can work..How do you make a reference???CONTROL TEXT:<BR><BR>Public MustInherit Class tttcontrol<BR> Inherits System.Web.UI.UserControl<BR><BR> Private rBox As TextBox<BR>#Region " Web Form Designer Generated Code "<BR><BR> 'This call is required by the Web Form Designer.<BR> <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<BR><BR> End Sub<BR><BR> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init<BR> 'CODEGEN: This method call is required by the Web Form Designer<BR> 'Do not modify it using the code editor.<BR> InitializeComponent()<BR> End Sub<BR><BR>#End Region<BR><BR> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<BR> 'Put user code to initialize the page here<BR> End Sub<BR><BR> Public Sub InitBox(ByRef Box As TextBox)<BR> rBox = Box<BR> End Sub<BR><BR> Public Sub UpdateBox()<BR> rBox.Text = "aaa"<BR> End Sub<BR>End Class<BR><BR><BR>PAGE TEXT<BR><BR>Public Class WebForm3<BR> Inherits System.Web.UI.Page<BR> Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox<BR> Protected WithEvents Tttcontrol1 As store.tttcontrol<BR><BR>#Region " Web Form Designer Generated Code "<BR><BR> 'This call is required by the Web Form Designer.<BR> <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<BR><BR> End Sub<BR><BR> Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init<BR> 'CODEGEN: This method call is required by the Web Form Designer<BR> 'Do not modify it using the code editor.<BR> InitializeComponent()<BR> End Sub<BR><BR>#End Region<BR><BR> Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<BR> 'Put user code to initialize the page here<BR> Tttcontrol1.InitBox(TextBox1)<BR> Tttcontrol1.UpdateBox()<BR> End Sub<BR><BR>End Class<BR><BR><BR><BR><BR>
 
Back
Top