Syntax Highlighter is cool

I’m just testing out Syntax Highlighter and it’s the dogzblx for publishing code snippets eg:

using System;
using System.Collections;
using System.Data;
using System.IO;
using System.Xml;
using System.Xml.Serialization;

namespace steve.BindingCustomCollections3.ObjectDeclarations{

	[Serializable]
	[XmlRoot("Employees")]
	public class Employees: ICollection{

		private DataTable employeeTable;
		private DataView employeeView;    

		internal Employees(DataTable employeeTable){
			this.employeeTable = employeeTable;
			this.employeeView = new DataView(employeeTable, "", "", DataViewRowState.CurrentRows);
			this.employeeView.ApplyDefaultSort = true;
		}

		public int Count{
			get{
				return (employeeView.Count);
			}
		}

		public Employee this[int indexer]{
			get {
				//Check if the indexer falls in allowable range.
				if ((indexer >= 0) &&
					(indexer < employeeView.Count))
					return (new Employee(employeeView[indexer].Row));
				else
					throw new System.IndexOutOfRangeException("Index must be between 0 and " +
						employeeView.Count.ToString() + ".");
			}
		}

		public Employee FindById(int id){
			int index = employeeView.Find(id);
			if(index == -1){
				return null;
			}
			else{
				return(new Employee(employeeView[index].Row));
			}
		}

		public IEnumerator GetEnumerator(){

			return new EmployeesEnumerator(employeeView);
		}

		public object SyncRoot{
			get{return employeeTable.Rows.Count;}
		}             

		public bool IsSynchronized{
			get{return false;}
		}      

		public void CopyTo(Array a, int offset){

			for(int index = 0; index < this.Count; index++){
				a.SetValue(new Employee(employeeView[index].Row), index + offset);
			}

		}
	}

}

My never ending Ajax hassle

OK so I have played about with Ajax years ago but I’ve always been skeptical about including it in enterprise applications due to the grief it gives me. Most of the Ajax I put in applications invariably causes me to rip it out at some point or other. I really like the effects of Ajax but it frustrates me that it breaks existing functionality.

This week for the first time in ages I thought ok lets give Ajax another chance.

This is the scenario: I have a masterpage which contains a header user control, in that header user control is a ‘login’ hyperlink that directs to a login page where a user can get authenticated etc. I thought it would be neat to use a ModalPopupExtender with a panel so that the login functionality would not require a full postback etc. So I include my login panel and ModalPopupExtender in my header control and plumb in the authentication code etc. All works fine. But then as I go into my admin section I find that pages (which derive from the same masterpage) that contain other user and custom controls dont function correctly. In particular I have a page which contains a control with a datagrid (yes datagrid – its an old app) inside it. The OnUpdateCommand now doesnt fire. Ive tried changing the way I hook up the event handlers eg:

this.dgEditor.UpdateCommand +=
new System.Web.UI.WebControls.DataGridCommandEventHandler(this.dgEditor_UpdateCommand);

or decleratively within the Datagrid markup. Neither makes a difference.

However if I comment the Ajax modal popup and associated panel then all works again. I get frustrated because I feel I should not have to spend time debugging this kind of stuff. I’d rather be debugging more important complex buisness logic.

Anyway rather than submit the code yet does anyone else have these kind of issues and am I missing something when I assume I can quickly just plumb in some stuff from the Ajax toolkit and expect it not to break existing, seemingly unrelated code.