Click here to Skip to main content
15,902,777 members
Home / Discussions / C#
   

C#

 
GeneralRe: ExecuteNonQuery returns -1 Pin
creganc1-Sep-04 11:28
creganc1-Sep-04 11:28 
GeneralRe: ExecuteNonQuery returns -1 Pin
Charlie Williams1-Sep-04 12:26
Charlie Williams1-Sep-04 12:26 
GeneralRe: ExecuteNonQuery returns -1 Pin
creganc1-Sep-04 12:33
creganc1-Sep-04 12:33 
GeneralExpense Management tool in C# Pin
MT_SEA1-Sep-04 9:12
MT_SEA1-Sep-04 9:12 
GeneralDetermining if a file is locked by another process Pin
nhoellei1-Sep-04 9:06
nhoellei1-Sep-04 9:06 
GeneralRe: Determining if a file is locked by another process Pin
Heath Stewart1-Sep-04 15:47
protectorHeath Stewart1-Sep-04 15:47 
GeneralRe: Determining if a file is locked by another process Pin
Pradeep Shamarao2-Sep-04 21:00
Pradeep Shamarao2-Sep-04 21:00 
GeneralEvent handling in Custom Server Controls Pin
gorebash1-Sep-04 7:50
gorebash1-Sep-04 7:50 
Please help me with this problem: I have a custom ToolBar control, which instantiates a PageSizeCbo, a custom server control which inherits from DropDownList. The ToolBar and the PageSizeCbo render on the page fine, but no events seem to fire.

Here is the ToolBar class:
<br />
<br />
using System;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
<br />
namespace QuoteBuilder_0_3.Controls.ToolBar {<br />
	<br />
	public class ToolBar : Control, INamingContainer {<br />
		private System.Collections.ArrayList toolList = new System.Collections.ArrayList(10);<br />
		public enum ToolType { PageSizeCbo=0 }<br />
		<br />
		public ToolBar() {}<br />
<br />
		private void build () {<br />
			Controls.Add(new LiteralControl("<div class='ToolbarContainer'>"));<br />
			Table table = new Table();<br />
			table.CssClass = "Toolbar";<br />
			TableRow row = new TableRow();<br />
			TableCell sepCell = new TableCell();<br />
			sepCell.CssClass = "ToolbarSeparatorCell";<br />
			sepCell.Controls.Add(new LiteralControl("|"));<br />
			for (int i=0; i<toolList.Count; i++) {<br />
				if (null == toolList[i])<br />
					break;<br />
				TableCell btnCell = new TableCell();<br />
				btnCell.CssClass = "ToolbarButtonCell";<br />
				btnCell.Controls.Add((Control)toolList[i]);<br />
				row.Cells.Add(btnCell);<br />
				row.Cells.Add(sepCell);<br />
			}<br />
			table.Rows.Add(row);<br />
			Controls.Add(table);<br />
			Controls.Add(new LiteralControl("</div>"));<br />
		}<br />
<br />
		public void AddTool (ToolType toolType) {<br />
			switch (toolType) {<br />
				case ToolType.PageSizeCbo:<br />
					toolList.Insert((int)toolType, new PageSizeCbo());<br />
					break;<br />
			}<br />
		}<br />
<br />
		protected override void Render(System.Web.UI.HtmlTextWriter writer) {<br />
			build();<br />
			base.Render (writer);<br />
		}<br />
<br />
		protected override bool OnBubbleEvent(object source, EventArgs args) {<br />
			Context.Response.Write("bubble handled!");<br />
			return true;<br />
		}<br />
	}<br />
}<br />


And here is the PageSizeCbo:
<br />
using System;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
<br />
namespace QuoteBuilder_0_3.Controls.ToolBar {<br />
	public class PageSizeCbo : DropDownList, IToolBarTool {<br />
		private const int TOTAL_OPTIONS = 5;<br />
		private int [] pageSizeValues = new int[TOTAL_OPTIONS] { 0, 10, 25, 50, 100 };<br />
		private string [] pageSizeDisplay = new string[TOTAL_OPTIONS] { "Unlimited", "10", "25", "50", "100" };<br />
		<br />
		public PageSizeCbo() : base() {<br />
			SelectedIndexChanged += new EventHandler(PageSizeCbo_SelectedIndexChanged);<br />
			Build();<br />
		}<br />
<br />
		public Control Build () {<br />
			for (int i=0; i<TOTAL_OPTIONS; i++) {<br />
				Items.Add(new ListItem(pageSizeDisplay[i], pageSizeValues[i].ToString()));<br />
			}<br />
			CssClass = "pageSizeCombo";<br />
			EnableViewState = true;<br />
			AutoPostBack = true;<br />
			return this;<br />
		}<br />
<br />
		private void PageSizeCbo_SelectedIndexChanged(object sender, EventArgs e) {<br />
			Context.Response.Write("Raising Bubble Event...<br/>");<br />
			RaiseBubbleEvent(sender, e);<br />
		}<br />
<br />
		protected override bool OnBubbleEvent(object source, EventArgs args) {<br />
			Context.Response.Write("Handling bubble from base cbo...");<br />
			return false;<br />
		}<br />
	}<br />
}<br />


I am new to custom server controls, so any help would be very appreciated!

Thanks,
Brent
GeneralRe: Event handling in Custom Server Controls Pin
Charlie Williams1-Sep-04 8:40
Charlie Williams1-Sep-04 8:40 
Generallocation based system Pin
mathon1-Sep-04 7:16
mathon1-Sep-04 7:16 
GeneralRe: location based system Pin
Heath Stewart1-Sep-04 15:33
protectorHeath Stewart1-Sep-04 15:33 
QuestionHow to cut a picture...?? Pin
Member 9401251-Sep-04 6:47
Member 9401251-Sep-04 6:47 
QuestionHow can I get width of window of my program when it change? Pin
arbrsoft1-Sep-04 5:51
arbrsoft1-Sep-04 5:51 
AnswerRe: How can I get width of window of my program when it change? Pin
LongRange.Shooter1-Sep-04 7:34
LongRange.Shooter1-Sep-04 7:34 
QuestionUnable to capture USB Gamepad using DirectInput? Pin
zhaonian1-Sep-04 4:57
zhaonian1-Sep-04 4:57 
AnswerRe: Unable to capture USB Gamepad using DirectInput? Pin
Heath Stewart1-Sep-04 15:27
protectorHeath Stewart1-Sep-04 15:27 
GeneralData Marshalling issues when Calling C++ dll in C# using P/Invoke Pin
KZHU011-Sep-04 4:17
KZHU011-Sep-04 4:17 
GeneralRe: Data Marshalling issues when Calling C++ dll in C# using P/Invoke Pin
Heath Stewart1-Sep-04 15:23
protectorHeath Stewart1-Sep-04 15:23 
GeneralNUnit - Specifying the order of Tests Pin
matthias s.1-Sep-04 3:44
matthias s.1-Sep-04 3:44 
GeneralRe: NUnit - Specifying the order of Tests Pin
Marc Clifton1-Sep-04 4:12
mvaMarc Clifton1-Sep-04 4:12 
GeneralRe: NUnit - Specifying the order of Tests Pin
Steven Campbell1-Sep-04 7:44
Steven Campbell1-Sep-04 7:44 
GeneralAxWebBrowser, BeforeNavigate2Event, postData problem Pin
Member 12847121-Sep-04 3:14
Member 12847121-Sep-04 3:14 
QuestionDrawing Window on Second Display...? Pin
jkersch1-Sep-04 1:14
jkersch1-Sep-04 1:14 
AnswerRe: Drawing Window on Second Display...? Pin
Marc Clifton1-Sep-04 2:58
mvaMarc Clifton1-Sep-04 2:58 
GeneralRe: Drawing Window on Second Display...? Pin
jkersch1-Sep-04 3:36
jkersch1-Sep-04 3:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.