M
msnews.microsoft.com
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
}
}
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
}
}