Tuesday, 29 April 2008

C# Constructors

See full discussion here

Base

public myClass() : base()

Overload

class myClass
{
public myClass()
{
//No parameters
}

public myClass(string param1) : this()
{
//No parameters will be called before me!
}
}

Monday, 28 April 2008

Asp.Net : "A first chance exception"

Getting huge amount of "A first chance exception" messages when running web-site under IDE for first time (after a rebuild).

These were being reported because programmer had turned off 'Just my code' within Tools->Options->Debugging->General

Tuesday, 22 April 2008

SQL Server : Query on date and HQL

Date format is 'YYYY-MM-DD'

e.g.

select * from orders where Date='2008-04-22'



HQL (as literal)

from Activity a where a.Date between '2008-01-01' and '2008-02-29'

Thursday, 3 April 2008

Bind Dictionary to WinForm ComboBox

To bind a dictionary to a combo box:

 

            cmbTable.DisplayMember = "Key";
cmbTable.ValueMember = "Value";
cmbTable.DataSource = new BindingSource(myDictionary, null);

Friday, 7 March 2008

Validators and hidden fields

It seems that there is a strange bug with validators.

If the field that is being validated is hidden in some circumstances a Java error " 'null' is null or not a object"

This doesn't happen on all servers / clients, the problem on site was produced on the clients IIS but on our one wasn't showing, this is with the same code running.
It also didn't happen with a previous version that had one less validator.

The solution was to move the validators next to the actual fields that were being validated. The validation messages were being shown in a validator summary.

The only way I could reproduce it in the office, was to move the post buttons off the Update panel and to do a full postback. This error continued to happen on site, even if I disabled the validators for the hidden control.s

Tuesday, 12 February 2008

IIS Asp.Net (Apparently) Bizzarro (turns out) lack of understanding

Had apparently strange goings on with IIS & Asp.Net.

Delivered new mylibrary.dll. User renamed mylibrary.dll to "old mylibrary.dll", copied in new mylibrary.dll. Got error saying 'old mylibrary.dll' could not be loaded into manifest.

After deleting the 'old mylibrary.dll' files the web site loaded ok.

After a discussion we came to the conclusion that IIS loads all the DLL files in the BIN directory irrespective of references within Web.Config.

The site then throws exception when two dlls contain the same Assembly-name - this also makes sense.

So what appeared to be strange behaviour came down to not thinking logically!

Monday, 4 February 2008

Asp.Net Ajax Calendar Extender

There is a bug with the AJAX calendar extender in that the style of the popup calendar are not applied if the text-box /calendar extender are hidden when a page first loads.

e.g. Panel with Details on is only shown once valid record found; if the first calendar extender on the page is within this hidden Details panel the calendar will not be displayed correctly when Details does become visible:

image

To fix this have a hidden calendar extender at top of the page:

<!-- Workaround for Calendar not displaying correctly - if hidden when page first loads -->
<div style="display: none"><asp:TextBox runat="server" ID="textbox1" /><cc1:CalendarExtender ID="ceTextBox1" runat="server" TargetControlID="textbox1" /></div>


Calendar is then displayed correctly:



image