Results 1 to 2 of 2

Thread: help

  1. #1
    Join Date
    Dec 1969

    Default help

    Hi,<BR>Could be a silly question.<BR>I have 2 classes as written below.<BR>how can i make the control tv (in WebForm1 class) to be available in test class.<BR>thanks<BR>Reb<BR><BR>using System;<BR>using System.Collections;<BR>using System.ComponentModel;<BR>using System.Data;<BR>using System.Drawing;<BR>using System.Web;<BR>using System.Web.SessionState;<BR>using System.Web.UI;<BR>using System.Web.UI.WebControls;<BR>using System.Web.UI.HtmlControls;<BR>using Microsoft.Web.UI.WebControls;<BR><BR>namespace Treeview<BR>{<BR> Public class WebForm1 : System.Web.UI.Page<BR> {<BR> public Microsoft.Web.UI.WebControls.TreeView tv;<BR><BR> public void Page_Load(object sender, System.EventArgs e)<BR> {<BR> TreeNode root = new TreeNode();<BR> root.Text = "Root";<BR> <BR> TreeNode child1 = new TreeNode();<BR> child1.Text = "Test";<BR> root.Nodes.Add(child1);<BR> tv.Nodes.Add(root);<BR> }<BR><BR>#region Web Form Designer generated code<BR> override protected void OnInit(EventArgs e)<BR> {<BR> //<BR> // CODEGEN: This call is required by the ASP.NET Web Form Designer.<BR> //<BR> InitializeComponent();<BR> base.OnInit(e);<BR> }<BR> <BR> /// &#060;summary&#062;<BR> /// Required method for Designer support - do not modify<BR> /// the contents of this method with the code editor.<BR> /// &#060;/summary&#062;<BR> private void InitializeComponent()<BR> { <BR> this.Load += new System.EventHandler(this.Page_Load);<BR><BR> }<BR> #endregion<BR> }<BR><BR> public class test <BR> {<BR> WebForm1 b = new WebForm1();<BR> public string test1<BR> { <BR> }<BR> }<BR>}<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: help

    If you have both classes in the same file then all you should need to do is create an instance of the first class in the second.<BR><BR>Like: <BR>myInstance mySecondClass <BR>I think or in VB it looks like<BR>Dim myInstance as mySecondClass<BR><BR>However if you have them in seprate files then you need to complie the class you want to use into a DLL and then use the "using" command to import it into your second class and again create an instance of the class.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts