ASP.NET: Postbacks for Algernon
We're hip deep into this bank today. Doing some amazing stuff and making a very rich user experience with as few moving parts as possible. Reuse, Reuse, Reuse.
Here are some interesting things I've learned/been reminded of
- Pretty PostBacks when using RewritePath: When you call HttpContext.RewritePath to make “junk.aspx?specialparam=Y“ look like “someotherpage.aspx“ it will look nice in the Browser's Location Bar, but not in the Form Action. Consequently, when you postback, you'll see the ugly URL in the Browser's Location Bar.
- So, call Page.RegisterStartupScript with this little block:
public void GridDataBound(Object sender, DataGridItemEventArgs e)
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
string target = string.Empty;
HyperLink linkCancel = new HyperLink();
LinkButton linkButtonCancel = (LinkButton)e.Item.Cells[CancelColumn].FindControl("LinkButtonCancel");
linkEdit.Text = linkButtonEdit.Text;
target = Page.GetPostBackEventReference(linkButtonEdit);
linkButtonCancel.Visible = false;