The Artima Developer Community
Sponsored Link

.NET Buzz Forum
ASP.NET: Postbacks for Algernon

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Scott Hanselman

Posts: 1031
Nickname: glucopilot
Registered: Aug, 2003

Scott Hanselman is the Chief Architect at Corillian Corporation and the Microsoft RD for Oregon.
ASP.NET: Postbacks for Algernon Posted: Nov 20, 2003 1:06 PM
Reply to this message Reply

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.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Scott Hanselman
Latest Posts From Scott Hanselman's ComputerZen.com

Advertisement

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:

      Page.RegisterStartupScript("rewritepathfix","<script language='javascript'>document.YourFormNameHere.action = document.location.href;</script>");
  • 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.

      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);
            linkCancel.NavigateUrl = GetConfirmJavascript(e.Item.DataItem as MyObject, target);
            linkButtonCancel.Visible = false;
            e.Item.Cells[CancelColumn].Controls.Add(linkCancel);
         }
      }

Read: ASP.NET: Postbacks for Algernon

Topic: Get ready for obsolete stuff in Whidbey today Previous Topic   Next Topic Topic: [tool] Total Commander 6.0 is out

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use