Please Help - New in Creating WEB CONTROLS

Discussion in 'ASP .Net' started by msnews.microsoft.com, Apr 27, 2005.

  1. Hello All,

    I created a control and it is not showing up in my Web Page?

    I am new to this. Can somebody please explain what I am doing wrong.

    Thanks
    Anand Ganesh

    Here is my control code. Below this code I have posted my Main Code which is
    accessing this control.


    /// WEB CONTROL CODE
    using System;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.ComponentModel;

    using System.Collections ;

    namespace NobelSystemsControls

    {

    public class WebControlPickOneValue : System.Web.UI.WebControls.WebControl

    {

    ArrayList ListofAllValues = new ArrayList() ;

    string SelectedValueName = "" ;

    int SelectedIndex = -1 ;

    public void PerformHandShake(ArrayList InList)

    {

    this.ListofAllValues = InList ;

    }


    /// <summary>

    /// Render this control to the output parameter specified.

    /// </summary>

    /// <param name="output"> The HTML writer to write out to </param>

    protected override void Render(HtmlTextWriter output)

    {

    }

    protected override void CreateChildControls()

    {

    ListBox TheListBox = new ListBox() ;

    foreach(string eachst in this.ListofAllValues)

    {

    TheListBox.Items.Add(eachst) ;

    }

    TheListBox.SelectedIndexChanged +=new
    EventHandler(TheListBox_SelectedIndexChanged);

    this.Controls.Add(TheListBox) ;

    //base.CreateChildControls ();

    }

    private void TheListBox_SelectedIndexChanged(object sender, EventArgs e)

    {

    ListBox INListBox = (ListBox) sender ;

    this.SelectedValueName = INListBox.SelectedItem.ToString() ;

    this.SelectedIndex = INListBox.SelectedIndex ;

    }

    }

    }



    /// The MAIN Code calling the CONTROL



    using System;

    using System.Collections;

    using System.ComponentModel;

    using System.Data;

    using System.Drawing;

    using System.Web;

    using System.Web.SessionState;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.Web.UI.HtmlControls;

    namespace WebApplication

    {

    /// <summary>

    /// Summary description for WebForm1.

    /// </summary>

    public class WebForm1 : System.Web.UI.Page

    {

    protected NobelSystemsControls.WebControlPickOneValue
    WebControlPickOneValue1;


    private void Page_Load(object sender, System.EventArgs e)

    {

    // Put user code to initialize the page here

    ArrayList ToGo = new ArrayList() ;

    ToGo.Add("0") ;

    ToGo.Add("1") ;

    ToGo.Add("2") ;

    ToGo.Add("3") ;

    ToGo.Add("4") ;

    ToGo.Add("5") ;

    ToGo.Add("6") ;

    ToGo.Add("7") ;

    ToGo.Add("8") ;

    ToGo.Add("9") ;

    ToGo.Add("10") ;

    this.WebControlPickOneValue1.PerformHandShake(ToGo) ;

    }

    #region Web Form Designer generated code

    override protected void OnInit(EventArgs e)

    {

    //

    // CODEGEN: This call is required by the ASP.NET Web Form Designer.

    //

    InitializeComponent();

    base.OnInit(e);

    }


    /// <summary>

    /// Required method for Designer support - do not modify

    /// the contents of this method with the code editor.

    /// </summary>

    private void InitializeComponent()

    {

    this.Load += new System.EventHandler(this.Page_Load);

    }

    #endregion




    }

    }
    msnews.microsoft.com, Apr 27, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KK
    Replies:
    2
    Views:
    550
    Big Brian
    Oct 14, 2003
  2. Nathan Sokalski
    Replies:
    5
    Views:
    1,006
    Gaurav Vaish \(www.Edujini-Labs.com\)
    Jan 10, 2007
  3. Nathan Sokalski
    Replies:
    4
    Views:
    284
    Nathan Sokalski
    Dec 21, 2006
  4. Nathan Sokalski
    Replies:
    4
    Views:
    318
    Nathan Sokalski
    Dec 21, 2006
  5. fs

    error when creating new web app. - help please

    fs, Oct 14, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    134
Loading...

Share This Page