This post originated from an RSS feed registered with .NET Buzz
by Scott Hanselman.
Original Post: ASP.NET: Postbacks for Algernon
Feed Title: Scott Hanselman's ComputerZen.com
Feed URL: http://radio-weblogs.com/0106747/rss.xml
Feed Description: Scott Hanselman's ComputerZen.com is a .NET/WebServices/XML Weblog. I offer details of obscurities (internals of ASP.NET, WebServices, XML, etc) and best practices from real world scenarios.
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:
Complex Custom Confirmation Dialogs on LinkButtons in DataGrids while STILL
maintaining PostBacks (whew!): If you want to have a javascript:confirm()
dialog popup when clicking on a LinkButton (not a Button), BUT you want the javascript
dialog to contain a context-specific message based on data, AND you still want a PostBack
event to occur:
Chain the JavaScript events by grabbing the LinkButton in the Grid's ItemDataBound.
Make a parallel HyperLink with an onclick that contains your javascript confirm, THEN
the PostBack javascript, which can be got to via Page.GetPostBackEventReference.
In this example the function GetConfirmJavascript builds
a confirm(”yada yada”) string based on the object passed in.