CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 11/29/2005 10:48:35 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 17 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
TonyC
Asp.Net User
Multiple composite controls on a page and event firing unexpectedly11/29/2005 10:48:35 PM

0/0

Ok....

I have a composite control I wrote. Let's call it TextBoxCalendar (TBC). If someone has a better name, let me know. Anyway, it contains the following:
1. TextBox
2. LinkButton
3. Image
4. Calendar

My intent is to let a user either enter a date into the TextBox or pick a date from the Calendar. To get access to the Calendar, you click on the LinkButton. This hides the TextBox, LinkButton, and Image and shows the Calendar. When the Calendar's SelectionChanged event fires, it hides the Calendar, populates the TextBox with the new SelectedDate, shows the TextBox, LinkButton, and Image.

So pretty straight forward, right?

When I put multiple TBCs on a web page and I click one of the first TBC's LinkButton, the first TBC behaves as expected. However, all the other TBCs on the page will suddenly show their Calendars. Does anyone know what is happening and/or how to fix it?

I've specified IDs for each control in the TBC and IDs for each TBC on the page. The TBC also implements INamingContainer.
kashif
Asp.Net User
Re: Multiple composite controls on a page and event firing unexpectedly11/30/2005 1:30:57 AM

0/0

I tried some simple code to repro the behavior you described above but was unable to see the erroneous behavior as described above. Can you post the custom control code?

<code>

public class Class1 : CompositeControl, INamingContainer
{
private Calendar calendar1;
private LinkButton linkbutton1;
private TextBox textbox1;
private Image image1;
public Class1()
{
calendar1 =
new Calendar();
linkbutton1 =
new LinkButton();
textbox1 =
new TextBox();
image1 =
new Image();
calendar1.SelectionChanged +=
new EventHandler(calendar1_SelectionChanged);
linkbutton1.Click +=
new EventHandler(linkbutton1_Click);
calendar1.ID =
"cal1";
calendar1.Enabled =
false;
linkbutton1.ID =
"lb1";
linkbutton1.Text =
"click me";
textbox1.ID =
"tb1";
image1.ID =
"img1";
image1.ImageUrl =
"~/foo.jpg";
}

protected void calendar1_SelectionChanged(Object o, EventArgs e)
{
textbox1.Text = calendar1.SelectedDate.ToShortDateString();
linkbutton1.Visible =
true;
textbox1.Visible =
true;
calendar1.Enabled =
false;
}

protected void linkbutton1_Click(Object o, EventArgs e)
{
linkbutton1.Visible =
false;
textbox1.Visible =
false;
calendar1.Enabled =
true;
}

protected override void CreateChildControls()
{
if (!this.ChildControlsCreated)
{
this.Controls.Add(calendar1);
this.Controls.Add(image1);
this.Controls.Add(textbox1);
this.Controls.Add(linkbutton1);
}
base.CreateChildControls();
}

protected override void Render(HtmlTextWriter writer)
{
writer.Write(
"Begin control");
base.Render(writer);
writer.Write(
"End control");
}
}
</code>

Thanks,
Kashif

TonyC
Asp.Net User
Re: Multiple composite controls on a page and event firing unexpectedly11/30/2005 2:00:21 AM

0/0

Here's my source code. What do you think?
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;

namespace BP.Legal.LDT.WebControls
{
	/// 
	/// Summary description for TextBoxCalendar.
	/// 
	[DefaultProperty("Text"), 
	ToolboxData("<{0}:TextBoxCalendar runat=server>")]
	public class TextBoxCalendar : System.Web.UI.WebControls.WebControl, System.Web.UI.INamingContainer
	{
		protected System.Web.UI.WebControls.TextBox DateTextBox = new TextBox();
		protected System.Web.UI.WebControls.LinkButton CalendarButton = new LinkButton();
		protected System.Web.UI.WebControls.Image CalendarIcon = new Image();
		protected System.Web.UI.WebControls.Calendar Calendar1 = new Calendar();
		protected System.Web.UI.WebControls.CompareValidator DateCompareValidator = new CompareValidator();
		private DateTime date;

		[Bindable(true), 
		Category("Appearance"), 
		DefaultValue("")]
		public DateTime DefaultDate
		{
			get { return this.date; }
			set { this.date = value; }
		}

		[Bindable(true), 
		Category("Appearance"), 
		DefaultValue("")]
		public string TextBoxCssClass
		{
			get 
			{ 
				return this.DateTextBox.CssClass;
			}
			set 
			{
				this.EnsureChildControls();
				this.DateTextBox.CssClass = value;
			}
		}

		[Bindable(true), 
		Category("Appearance"), 
		DefaultValue("")]
		public string ButtonCssClass
		{
			get 
			{ 
				return this.CalendarButton.CssClass;
			}
			set 
			{ 
				this.EnsureChildControls();
				this.CalendarButton.CssClass = value;
			}
		}

		///  
		/// Render this control to the output parameter specified.
		/// 
		///  The HTML writer to write out to 
		protected override void Render(HtmlTextWriter output)
		{
			this.DateTextBox.RenderControl(output);
			this.CalendarButton.RenderControl(output);
			this.DateCompareValidator.RenderControl(output);
			this.Calendar1.RenderControl(output);
		}

		protected override void CreateChildControls()
		{
			base.CreateChildControls ();

			this.DateTextBox.ID = "DateTextBox";
			this.Controls.Add(this.DateTextBox);
			
			this.CalendarButton.ID = "CalendarButton";
			this.CalendarButton.Click += new EventHandler(CalendarButton_Click);
			this.Controls.Add(this.CalendarButton);
			
			this.CalendarButton.Controls.Add(this.CalendarIcon);

			this.Calendar1.ID = "Calendar1";
			this.Calendar1.SelectionChanged += new EventHandler(Calendar1_SelectionChanged);
			this.Controls.Add(this.Calendar1);

			this.DateCompareValidator.ID = "DateCompareValidator";
			this.DateCompareValidator.ControlToValidate = this.DateTextBox.ID;
			this.DateCompareValidator.Display = ValidatorDisplay.Dynamic;
			this.DateCompareValidator.ErrorMessage = "Error message goes here.";
			this.DateCompareValidator.Operator = ValidationCompareOperator.DataTypeCheck;
			this.DateCompareValidator.Type = System.Web.UI.WebControls.ValidationDataType.Date;
			this.Controls.Add(this.DateCompareValidator);
		}

		private void Calendar1_SelectionChanged(object sender, EventArgs e)
		{
			this.date = this.Calendar1.SelectedDate;

			this.DateTextBox.Text = this.date.ToShortDateString();

			this.Calendar1.Visible = false;
			this.DateTextBox.Visible = true;
			this.CalendarButton.Visible = true;
			this.DateCompareValidator.Visible = true;
		}

		protected override void OnLoad(EventArgs e)
		{
			base.OnLoad (e);

			this.EnsureChildControls();

			if (! this.Page.IsPostBack)
			{
				this.DateTextBox.Visible = true;
				if (this.date != DateTime.MinValue)
					this.DateTextBox.Text = this.date.ToShortDateString();

				this.CalendarButton.Visible = true;
				this.Calendar1.Visible = false;
				this.DateCompareValidator.Visible = true;
			}
		}

		protected override void OnPreRender(EventArgs e)
		{
			base.OnPreRender (e);

			this.CalendarIcon.ImageUrl = this.Page.Request.ApplicationPath + System.Configuration.ConfigurationSettings.AppSettings["calendarIcon"];
		}

		private void CalendarButton_Click(object sender, EventArgs e)
		{
			if (! Page.IsValid)
				return;
			
			if (this.DateTextBox.Text == null || this.DateTextBox.Text == string.Empty)
				this.date = DateTime.Today;
			else
				this.date = DateTime.Parse(this.DateTextBox.Text);				

			this.Calendar1.SelectedDate = this.date;
			this.Calendar1.VisibleDate = this.date;

			this.DateTextBox.Visible = false;
			this.DateCompareValidator.Visible = false;
			this.CalendarButton.Visible = false;
			this.Calendar1.Visible = true;
			this.Page.Response.Write(this.Calendar1.ID);
		}
	}
}
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Progress in Brain Research Authors: F Nyberg, H S Sharma, Z Wiesenfeld-Hallin, Pages: 496, Published: 1985
Brain Mechanisms for the Integration of Posture and Movement Authors: Shigemi Mori, Douglas G. Stuart, Mario Wiesendanger, Patricia A. Pierce, National Institute for Physiological Research, Pages: 529, Published: 2004

Web:
Multiple composite controls on a page and event firing ... Multiple composite controls on a page and event firing unexpectedly. Last post 11-29-2005 9:00 PM by TonyC. 2 replies. Sort Posts: ...
.NET ASP Page 132 - Bytes Site Map How to Bubble an event from a dynamically created user control. ... ASP.NET and Websphere MQ · Whats wrong · Multiple assemblies, one prefix in aspx page? ...
List of bugs that are fixed in Microsoft .NET Framework 1.0 ... 326251 (http://support.microsoft.com/kb/326251/) Composite ActiveX controls do ... FIX: The validating event on the user control does not fire as expected ...
ASP.NET [Archive] - Page 30 - DevX.com Forums [Archive] Page 30 Issues related to the Active Server Pages Web server ... with multiple datasources · How to display WebUserControls on event fire? ...
ASP Net [Archive] - Page 157 [Archive] Page 157 microsoft.public.dotnet.framework.aspnet. ... on hardware specification · Is there a simpler way (trick) to create composite controls ? ...
UltraToolBars 1924 - Toolclick fires unexpectedly when displaying form modally in the .... 4983 - Crash in web page that hosts an ATL Lite Composite Control that contains ...
Derived Controls User controls are great for composite controlsthat wrap two or more existing . .... The final ingredient is to replace the AfterSelect event, which fires ...
>> Windows Forms >> Archive Page 147 51104: Context Menu events not firing immediately .... 51349: Exposing ListView Column Header Collection Editor on a composite control ...
TRULY Understanding ViewState Then the next_click event fires. You remove Step1.ascx from the page (you probably put it into a ..... I have one composite control with one dropdownlist. ...
KBAlertz.com: KBAlertz.com - Knowledge Base Alerts Q817979 OnChange Event Fires Unexpectedly When You Tab Out of a Text Area .... 274203 PRB: Cannot Shift Focus from an ATL Composite Control on a Web Page ...




Search This Site:










a blog matching the location you requested...error

need better search functionality

master.master.someproperty from page of a nested master fails at runtime (sometimes)

best method to implement authentication

reading files from visual studio team system "vsts"

a real riddle!

2005 installation ...

request for the permission of type 'system.security.permissions.securitypermission, mscorlib, version=2.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089' failed.

wtf - visual studio 2005, vista home premuim, ie7

menu control - sitemappath conrol and web.sitemap issue

uploading skins

my first module woes

dotnetnuke 2.0 beta i

could not find schema information for the element 'http://schemas.microsoft.com/.netconfiguration/v2.0:configuration'

user specific themes?

solpartmenu - root tab

login/ limit customer's information

courses to take (.net) to create web applications with sql 2000 access?

iseditable gives a system.nullreferenceexception

using start kit cant create a user

surce formating problem

new definition

menu control in master page does not get styles in ie 6.0

admin account inaccessible

help with website admin tool

how can i make my masterpage 100% in screan

3.0.4 images path - images used by the portal shows red x

change application for providers on a per-request basis

ie toolbar

dnn2.0.3 error returning to host portal.

 
All Times Are GMT