Posts

Showing posts from October, 2013

Donate

Close ToolStripDropdown Object When Parent Container Or Form Is Clicked In C# Windows Forms

To close the ToolStripDropdown object which is part of the textbox custom control, add event handler signatures and event definition using the code below: //add statements in the custom control constructor this .Parent.Click += new EventHandler(Parent_Click); this .Parent.Move += new EventHandler(Parent_Click); //event body private void Parent_Click( object sender, EventArgs e) { _dropDown.Close(); //ToolStripDropdown object } Cheers!

Focus Or Caret On TextBox Control Gone If ToolstripDropdown Is shown In Custom Controls Windows Forms C#

Im trying to implement a custom textbox control with auto-suggest features. Upon rendering the ToolStripDropdown object just below the textbox control, the focus seems to be lost. I found the trick by setting the AutoClose property to false in the Textbox OnHandleCreated(EventArgs e) event. See the code below: _dropDown.AutoClose = false ; //ToolStripDropDown object Greg

Include Foreign Key Columns In The Model Disabled (ADO.NET Entity Framework)

When adding database objects to your entity data model, The checkbox option labeled (Include foreign key columns in the model) might be disabled. I later found out that the class library's target framework was .NET 3.5 Framework. While the solution and asp.net website's target framework is .NET 4.0. The solution was to change the target framework to .NET 4.0 then recompiled the class library. Alas! the include foreign key columns is now enabled. Cheers!

Accessing App.Config Values In Class Library Not Working In C#

In a project that we are working with involves several class libraries. And one of them involves setting/getting the connection string. We simply added an application config file with the connection string in it. However, accessing the key/value of connection string returns null. One possible solution is to add a Settings file in the class library where you can set the connection string. And to access the connection string value, refer to the code below: //Settings is the Settings File. //SalesConnection is the Name of the connection string return new Settings().SalesConnection; Here's a similar post regarding Settings File: Setting app.config in ASP.NET Cheers!

AnimationExtender Animation Using JSON Not Working In ASP.NET

When setting animations for AnimationExtender control using JSON/Javascript, setting the AnimationTarget with the explicit control id such as panel ID does not work when rendered to browser specified by the code below: "AnimationTarget" : "panelDescription" The workaround is to get the clientID of the panel control rendered through the browser. Below is the workaround code: //Note: this is just a fragment of the JSON animation //the actual animation might be a little bit specific than this. var animation = "AnimationTarget":"' + '<%= panelDescription.ClientID %>' + '","AnimationChildren"'; //set click behavior animationExtender.set_OnClick(animation); Cheers!

Multiple controls with the same ID '_header' were found. FindControl requires In Asp.net Ajax

Good day! After integrating ajax accordion pane controls in my asp.net app, an exception pops up as stated by the title of the post. The culprit was that I initialized two AccordionPane objects w/o specifying the ID's of each object. The solution is to include ID's in each control.See example below: AccordionPane ap1 = new AccordionPane(); ap1.ID = "ap1" ; ap1.HeaderContainer.Controls.Add( new LiteralControl( "Product Code" )); ap1.ContentContainer.Controls.Add( new LiteralControl(datarow[ "ID" ].ToString();)); AccordionPane ap2 = new AccordionPane(); ap2.ID = "ap2" ; ap2.HeaderContainer.Controls.Add( new LiteralControl( "Product Name" )); ap2.ContentContainer.Controls.Add( new LiteralControl(datarow[ "Prod_Name" ].ToString();)) Cheers!

.NET 4.5 Framework Features

Image
Here's an image i got from  http://muralitharan.info  blog. Thanks to the guy who uploaded this image... :) Greg

Combobox With CheckListBox Supports Multi highlighting (C#)

Image
A control developed by: Stelios Alexandrakis which I found it cool is a combobox with checklistbox as the dropdown item. After fixing a few bugs, I integrate the feature of multi-highlighting based from the previous post on customizing CheckListBox control: CheckBoxList Multihighlight . Here's some screenshots to illustrate each of the custom controls.

CheckBoxList Control With Multi-Highlighting Support In C# Windows Forms

Image
If you want to customize the CheckBoxList control to support multi-highlighting (each checked item is highlighted), you can simply override the OnDrawItem() by adding Graphics statements as shown below: Here's an image sample of the extended CheckBoxList control: Code: protected override void OnDrawItem(DrawItemEventArgs e) { int index = e.Index; if ( this .GetItemCheckState(index) == CheckState.Checked) { string text = this .Items[index].ToString(); Graphics g = e.Graphics; Point point = this .GetItemRectangle(index).Location; point.X += estimated_point; //estimated point is a value you may set manually //background: SolidBrush backgroundBrush; backgroundBrush = reportsBackgroundBrushSelected; //estimated point is a value you may

Custom Extender Type Or Class Is Undefined In AjaxToolkit ASP.NET

Hi! When running an asp.net app that includes an ajax custom extender control, a javascript alert pops up message "EXTENDER is undefined". Sample error message: CustomExtenders.DisabledTextBehavior is undefined where: CustomExtenders.DisabledTextBehavior is Namespace.Type After troubleshooting for several hours, I came up with the solution: 1. Download Ajax Toolkit Stable Release for the specific .NET Framework.  I tried versions for September release and it's not working. 2. Replace code: CustomExtenders.DisabledTextBehavior.registerClass( 'CustomExtenders.DisabledTextBehavior' , AjaxControlToolkit.BehaviorBase); To CustomExtenders.DisabledTextBehavior.registerClass( 'CustomExtenders.DisabledTextBehavior' , Sys.Extended.UI.BehaviorBase); Note: AjaxControlToolkit.BehaviorBase is used in previous versions of AjaxToolkit. Cheers!

AjaxControlToolkit ExtenderControlBaseDesigner Class Requires T

Hello! The previous version of ExtenderControlBaseDesigner does not require T as parameter. However, in recent versions you might notice that the class is declared with T. Here's a sample declaration: AjaxControlToolkit.Design.ExtenderControlBaseDesigner<T> T means AjaxControlToolkit.ExtenderControlBase. In order for the Custom Extender Designer to work, supply the T with class that inherits the ExtenderControlBase. This sample class inherits the ExtenderControlBase: public class CustomPanelExtender : ExtenderControlBase { //your code goes here.... }

Show Smart Tag(Shift + Alt + F10) Is Disabled Or Greyed In ASP.NET Web Forms Server Control

When adding ajax extenders to asp.net server controls using Smart Tag, you often encounter an issue such as Show Smart Tag is greyed out/disabled. The best thing to do is to use the latest stable version of AjaxToolkit. And then, reset the toolbox. Sometimes, you have to close the Visual Studio IDE just to make sure. IDE Version: Visual Studio 2010 Professional Ajax Toolkit Binary: AjaxControlToolkit.Binary.NET4 (Stable Version) Cheers!

Donate