By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,949 Members | 2,038 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,949 IT Pros & Developers. It's quick & easy.

How to Create Web Controls using ASP.NET Controls ?

P: n/a
Hello All,

I am trying to write Web Controls and in most of the samples I came across,
I am seeing the following function where a HTML string is written to create
HTML Controls.
/// <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)

{

string TheHTMLString = FrameHTMLString() ;

output.Write(TheHTMLString) ;

}
Is it possible for me to use the asp:button or asp:panel in this webcontrol.
Also how will I setup events for such button click or panel mouse down
event?
Any suggestions please?

Thanks
Aand Ganesh


Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
These articles should give you a jump start in learning about how to create
web controls:

http://SteveOrr.net/articles/InheritAndExtend.aspx
http://SteveOrr.net/articles/ComboBox.aspx
http://SteveOrr.net/articles/BarGraphs.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"msnews.microsoft.com" <ag*****@nobel-systems.com> wrote in message
news:ux**************@TK2MSFTNGP09.phx.gbl...
Hello All,

I am trying to write Web Controls and in most of the samples I came
across, I am seeing the following function where a HTML string is written
to create HTML Controls.
/// <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)

{

string TheHTMLString = FrameHTMLString() ;

output.Write(TheHTMLString) ;

}
Is it possible for me to use the asp:button or asp:panel in this
webcontrol. Also how will I setup events for such button click or panel
mouse down event?
Any suggestions please?

Thanks
Aand Ganesh

Nov 19 '05 #2

P: n/a
Steve,

Thanks for the quick help.

Regards
Anand

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:uT**************@TK2MSFTNGP15.phx.gbl...
These articles should give you a jump start in learning about how to
create web controls:

http://SteveOrr.net/articles/InheritAndExtend.aspx
http://SteveOrr.net/articles/ComboBox.aspx
http://SteveOrr.net/articles/BarGraphs.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"msnews.microsoft.com" <ag*****@nobel-systems.com> wrote in message
news:ux**************@TK2MSFTNGP09.phx.gbl...
Hello All,

I am trying to write Web Controls and in most of the samples I came
across, I am seeing the following function where a HTML string is written
to create HTML Controls.
/// <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)

{

string TheHTMLString = FrameHTMLString() ;

output.Write(TheHTMLString) ;

}
Is it possible for me to use the asp:button or asp:panel in this
webcontrol. Also how will I setup events for such button click or panel
mouse down event?
Any suggestions please?

Thanks
Aand Ganesh


Nov 19 '05 #3

P: n/a
Steve,

I saw your sample and also I created my control based on your combobox
sample.

But my page is not even showing up the control.

Can you please let me know what I am missing?

Thanks
Anand

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

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


}

}



///////////// My code ////////////

"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:uT**************@TK2MSFTNGP15.phx.gbl...
These articles should give you a jump start in learning about how to
create web controls:

http://SteveOrr.net/articles/InheritAndExtend.aspx
http://SteveOrr.net/articles/ComboBox.aspx
http://SteveOrr.net/articles/BarGraphs.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"msnews.microsoft.com" <ag*****@nobel-systems.com> wrote in message
news:ux**************@TK2MSFTNGP09.phx.gbl...
Hello All,

I am trying to write Web Controls and in most of the samples I came
across, I am seeing the following function where a HTML string is written
to create HTML Controls.
/// <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)

{

string TheHTMLString = FrameHTMLString() ;

output.Write(TheHTMLString) ;

}
Is it possible for me to use the asp:button or asp:panel in this
webcontrol. Also how will I setup events for such button click or panel
mouse down event?
Any suggestions please?

Thanks
Aand Ganesh


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.