Thursday, April 19, 2012

Error: A connection was successfully established with the server, but then an error occurred during the pre-login handshake

The local machine suddenly started giving me the error

A connection was successfully established with the server, but then an error occurred during the pre-login handshake

In order to solve it, try the following


  1. Clean your Visual Studio solution
  2. Rebuild project
  3. Reset IIS
  4. Run the project again
This did the trick for me

Friday, April 13, 2012

AppendDataboundItems for ASPxCombobox

In order to mimic the 'AppendDataBound' feature found in normal ASP.NET comboboxes for devexpress and add items to a bound control, you need to use the databound event to insert the new values if you need a server side solution

protected void myComboBox_DataBound(object sender, EventArgs e)
        {
            myComboBox.Items.Add("All", "0").Index = 0;
            myComboBox.SelectedIndex = 0;
        }

You can also do it at client side by using the following code

comboBox.ClientSideEvents.Init = "function(s, e) {s.InsertItem(0, '(ALL)', '');}";



LINQ SubmitChanges() not working

Just a small note:

The problem was because the table did not have a primary key set.  The DataContext class requires a primary key to update

ASP.NET: Get/Set value from/to cookies

string cookieName;
private int CookieValue
    {
        get
        {
            int _intValue =0;
            if(Request.Cookies[cookieName] != null)
                int.TryParse(Request.Cookies[cookieName].Value, out _intValue);

            return _intValue;
        }
        set
        {
            if(Request.Cookies[cookieName] != null)
                Response.Cookies.Add(new HttpCookie(cookieName, Convert.ToString(value)));
            else
                Response.Cookies["cookieName"].Value = Convert.ToString(value);
        }
    }

Storing multiple values in cookies

Response.Cookies[cookieName]["age"] = 16;
Response.Cookies[cookieName]["Name"] = "John";
Response.Cookies[cookieName].Expires = DateTime.Now.AddDays(1);

Thursday, April 12, 2012

Batch file to launch applications with delay


Here is the code.  10 is the delay in seconds


ping –n 10 127.0.0.1>nul
start "" "C:\Program Files\Mozilla Firefox\firefox.exe"
start "" "C:\Program Files\Internet Explorer\iexplore.exe"


Short and simple :)