Archive for November, 2008

Changes in __doPostback in .NET 1.1 to .NET 2.0

Before and After

If you manually want to simulate a postback, Here is how you would stick together a string manually calling __doPostBack in .NET 1.1
In this case its making a link in a particular linkbutton control inside a datagrid.

__doPostBack in .NET 1.0

string link = "<a href=\"javascript:__doPostBack('dataGridCart$_ctl" + i + "$linkButton','');\"";

__doPostBack in .NET 2.0

string link = "<a href=\"javascript:__doPostBack('dataGridCart$ctl0" + i + "$linkButton','');\"";

Dont use this function any more.  Use Page.GetPostBackClientHyperlink from .NET 2.0+.  This is because they might change __doPostBack yet again and your code will be broken.

Look at the comment thread on this codeproject article for more details

Further reading: Do Postback Hijacking

Tracking Influenza (flu) with Google Trends

This is quite an astonishing use of Google Trends.  Google realized that when people get sick they (obviously) search for flu related keywords and they managed to find a correlation to actual published flu infection statistics.  Quite amazing and this is definately a unique and interesting application of technology.

How we track flu trends (Google blog)
Here is an explanation of how it works

What other ideas can we apply this to?

Read Pro ASP.NET 2.0 in C# free

Due to a recent agreement between Google and some book publishers, they are going to publish a large number of books online (limited content depending on each publishers agreement).

So you can now read Pro ASP.NET 2.0 C# for free online (a large chunk of it)!  Click the link for more.  This book is jam packed (1000 pages+) with well-written details on everything under the sun in .NET 2.0.  I was in particular looking for SQL Cache Dependency information which I found in there.

Apparently in SQL Server 2000, Cache Dependency is done on a table basis, you cannot have it dependent on a certain condition (for example select * from CONTACTS where location=’canada’).  If any data at all changes inside CONTACTS then the cache is considered invalidated and you will need fresh data.   Lots of improvements in SQL Server 2005 boys….

How to get session or other custom values into ELMAH

In “Timing is Everything” I mentioned how I successfully managed to convince management to install ELMAH.  I wanted to add some comments as to how to easily get some values into ELMAH that you might have in your SESSION.

The easy way, with no code changes, is simply store those values in a COOKIE.

HttpCookie c = new HttpCookie("CUSTOMVAL");
c.Value = (string) Session["CUSTOMVAL"];
Response.Cookies.Add(c);

Viola! It will be in the ELMAH Error page!

Optimization WordPress Plugins & Solutions by W3 EDGE