Scott Hanselman

ASP.NET: Postbacks for Algernon

November 20, '03 Comments [2] Posted in ASP.NET | Javascript
Sponsored By

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);
         }
      }

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

My Ultimate TabletPC

November 19, '03 Comments [4] Posted in Musings
Sponsored By

It's out and here's the scoop.

  •   Intel® Centrino™ Mobile Technology
  •   Microsoft® Windows XP Professional Tablet Edition
  •   Microsoft® Office OneNote™ 2003
  •   High resolution 12.1" SXGA+ (1400 x 1050) display*
  •   Up to 4.34 hours² battery time
  •   NVIDIA® GeForce™ FX Go5200 32M graphics w/32MB DDR memory
  •   Integrated Wi-Fi™ (802.11b), 10/100 Ethernet, V.90/56K modemº

It's got a 1.5Ghz Processor and up to a Gig of RAM.  Note that they wimped out on the 128Megs of RAM, but it DOES HAVE 1400x1050 RESOLUTION!

Sold. I mean, Bought.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Brainfart? or ASP.NET madness

November 19, '03 Comments [4] Posted in ASP.NET
Sponsored By

I need a function from ASP.NET that gives me, reliably and guaranteed, without a config file, the base virtual directory of the current website.  So if I'm in c:\inetpub\wwwroot\web (ne http://localhost/web) then I want “/web/.” 

But (here's the fart part) I can't seem to find a way that gives it to me INDEPENDANT of the current Context's path.  Meaning, if the VERY FIRST (app start) page hit on the site is http://localhost/web/balances/balances.aspx then I still need “/web/“ not “/web/balances/.“

This is the closest I've got:

return HttpRuntime.AppDomainAppVirtualPath + "/";

However, this appears to occasionally (read: flaky) return a different path like /web/images/ or /web/someotherpagedirectory. 

What am I missing?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

My Christmas (or Birthday List)

November 16, '03 Comments [5] Posted in Gaming
Sponsored By

So I was typing up a Christmas List (or birthday, as mine is in January) for the wife, and I figured certainly you, dear reader(s), would care to see it (I encourage you to do the same!):

In no particular order

Most wanted:

Wanted:

I hope you enjoy reading about them as much as I will enjoy getting them (well, I'll probably get just one)

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Microsoft SPOT or MSN Direct or Microsoft Wrist Net

November 16, '03 Comments [1] Posted in PDC
Sponsored By

One day this watch will finally come out and I will behappy.  Seems like so many different technologies get promoted by Microsoft and some really great ones get lost in the fray.  Remember Microsoft Ultimate TV?  It was a BETTER Tivo and it could record TWO SHOWS AT ONCE WITH TWO SEPARATE TUNERS.  I got the feeling it died because Microsoft let it die...rather that on any technical merit. 

I'm afraid now that SPOT will die due to lack of interest and a slipping schedule.  I4U is reporting that the Fossil SPOT (Microsoft Wrist.NET) watch won't ship until 2004, and the Suunto watch won't ship until 1/2004(They've got a nice gallery of all current SPOT watches up.)

It's a brilliant idea though...multicast data on empty FM radio bandwidth to watches identified basically by GUIDs.  No private data, just weather and traffic, but also calendars, email and IMs.  An information receiver on your wrist using an existing and proven information transmission medium.  FM Radio.  Brilliant.

But when I can buy it?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.