Changes in __doPostback in .NET 1.1 to .NET 2.0

November 27th, 2008 by Sameer | Filed under Uncategorized.

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

Other Interesting Posts

Leave a Reply