<?xml version="1.0" encoding="utf-8"?>
<feed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom">
  <title>The Moon Upstairs</title>
  <link rel="alternate" type="text/html" href="http://fredwebs.com/blog/" />
  <link rel="self" href="http://fredwebs.com/blog/SyndicationService.asmx/GetAtom" />
  <icon>favicon.ico</icon>
  <updated>2010-03-09T10:15:13.449-05:00</updated>
  <author>
    <name>Fred Peters</name>
  </author>
  <subtitle>And other .Net Programming Issues</subtitle>
  <id>http://fredwebs.com/blog/</id>
  <generator uri="http://dasblog.info/" version="2.2.8279.16125">DasBlog</generator>
  <entry>
    <title>Visual Studio Post Build Bug</title>
    <link rel="alternate" type="text/html" href="http://fredwebs.com/blog/2010/03/09/VisualStudioPostBuildBug.aspx" />
    <id>http://fredwebs.com/blog/PermaLink,guid,cab10b29-e543-4f76-bde6-df0363dc8221.aspx</id>
    <published>2010-03-09T18:11:00-05:00</published>
    <updated>2010-03-09T10:15:13.449-05:00</updated>
    <category term="Visual Studio" label="Visual Studio" scheme="http://fredwebs.com/blog/CategoryView,category,VisualStudio.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Here’s a bug I found in Visual Studio 2008.  Hopefully it will be fixed in the
2010 version.  Projects in a system I work on often have an Xcopy post build
commands to copy the DLL and PDB to a reference directory.  I recently added
one of these commands to an existing project:  
</p>
        <p>
xcopy /f /d /y 
</p>
        <p>
"D:\Work\casfw3\trunk\Source\Common\QuickAddressProv6\bin\Debug\*.*" 
</p>
        <p>
"D:\Work\casfw3\trunk\Source\Common\QuickAddressProv6\..\..\..\..\References\Common\" 
</p>
        <p>
if errorlevel 1 exit %25errorlevel%25 
</p>
        <p>
Visual Studio 2008 reported that it copied two files for the commands.  But when
you go and look for the files they are not to be found.  Of course I rebuilt
the project several times but a file search of the tree could not find the copied
files.
</p>
        <p>
I copied the command to a command line window and the Xcopy command returns “0 Files
Copied”.  I then realized I was trying to go up one too many folders (“..\”). 
I made the correction and using the command line the files were successfully copied
by Visual Studio.
</p>
        <img width="0" height="0" src="http://fredwebs.com/blog/aggbug.ashx?id=cab10b29-e543-4f76-bde6-df0363dc8221" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Altova Stylevision Error</title>
    <link rel="alternate" type="text/html" href="http://fredwebs.com/blog/2010/01/26/AltovaStylevisionError.aspx" />
    <id>http://fredwebs.com/blog/PermaLink,guid,c5229336-886d-4cd9-afac-e0cf49614986.aspx</id>
    <published>2010-01-26T18:14:00-05:00</published>
    <updated>2010-01-26T10:23:43.807375-05:00</updated>
    <category term="Stylevision" label="Stylevision" scheme="http://fredwebs.com/blog/CategoryView,category,Stylevision.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
From Brent Minder, who will not divulge how long it took to track this one down:
</p>
        <p>
Hey Guys, 
</p>
        <p>
Just wanted to let you know about a symptom when running a large Stylevision report
that blows up with a meaningless list of paragraph overflow warnings. This error occurs
when the java virtual machine exceeds its maximum heap space allotment. You can increase
the heap space in the fop.bat file like so: 
</p>
        <p>
  
</p>
        <p>
Look in <i>C:\Program Files\Altova\FOP-0.95\ (or C:\Program Files\Apache Group\FOP-0.94\)</i></p>
        <p>
  
</p>
        <p>
Open fop.bat and modify line 72 from: 
</p>
        <p>
          <b>
            <i>set JAVAOPTS=-Denv.windir=%WINDIR%</i>
          </b>
        </p>
        <p>
  
</p>
        <p>
to something like this: 
</p>
        <p>
          <b>
            <i>set JAVAOPTS=-Denv.windir=%WINDIR% -Xmx768m</i>
          </b>
        </p>
        <p>
  
</p>
        <p>
Here is more detail on the error: 
</p>
        <p>
          <a href="http://xmlgraphics.apache.org/fop/0.95/running.html#memory">http://xmlgraphics.apache.org/fop/0.95/running.html#memory</a>
        </p>
        <img width="0" height="0" src="http://fredwebs.com/blog/aggbug.ashx?id=c5229336-886d-4cd9-afac-e0cf49614986" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Jungle Disk Service Hangs Up</title>
    <link rel="alternate" type="text/html" href="http://fredwebs.com/blog/2009/10/01/JungleDiskServiceHangsUp.aspx" />
    <id>http://fredwebs.com/blog/PermaLink,guid,28e7b93e-5a31-4b6e-8fd2-b02028583f38.aspx</id>
    <published>2009-09-30T22:04:41.892625-04:00</published>
    <updated>2009-09-30T22:04:41.892625-04:00</updated>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
 
</p>
        <p>
I’ve been using <a href="http://www.jungledisk.com" target="_blank">Jungle Disk</a> for
nearly three years now for reliable, easy, and inexpensive cloud storage.  The
software uses Amazon S3 storage or their own Rackspace storage.  Since I currently
run five machines at home and one at work the network drive that Jungle Disk mounts
is great for storing large files.  It can also be configured to do automatic
backups.  For things that change everyday, I also run Windows Live Mesh.
</p>
        <p>
Recently on my new Vista machine the Jungle Disk service would just hang in the starting
state.  I tried reinstalling several times with the same result.  I resorted
to the Jungle Disk help desk.  
</p>
        <p>
The first response was disappointing: make Jungle Disk an exception in the firewall
and make sure ports 80 and 443 are open.  Since none of the other machines running
McAfee had this set, I didn’t think it would help.  But of course I tried it
to no avail.
</p>
        <p>
I specifically asked how to remove all program information before the installation. 
Every time I tried reinstalling the software I was never asked for my Amazon S3 information. 
I had assumed it was a registry entry, but in fact for Vista it is stored in an XML
file in C:\ProgramData\JungleDisk.  Removing the files in that location fixed
the problem and I was able to re-enter the Amazon information and run the program
without the service hanging.
</p>
        <p>
Only four or five hours of work for what I guess was a gamma ray striking some part
of my disk drive since there had been no configuration changes or installs to prompt
this behavior.
</p>
        <img width="0" height="0" src="http://fredwebs.com/blog/aggbug.ashx?id=28e7b93e-5a31-4b6e-8fd2-b02028583f38" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Updating to DasBlog 2.2</title>
    <link rel="alternate" type="text/html" href="http://fredwebs.com/blog/2008/12/24/UpdatingToDasBlog22.aspx" />
    <id>http://fredwebs.com/blog/PermaLink,guid,a35141c2-b54a-4cb9-a7bb-87ba761ebcfc.aspx</id>
    <published>2008-12-24T06:51:00-05:00</published>
    <updated>2008-12-23T22:52:34.325875-05:00</updated>
    <category term="ASP.Net" label="ASP.Net" scheme="http://fredwebs.com/blog/CategoryView,category,ASPNet.aspx" />
    <category term="Das Blog" label="Das Blog" scheme="http://fredwebs.com/blog/CategoryView,category,DasBlog.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
After a lot of false starts I finally updated this site to the latest version of DasBlog. 
I had been running the older version that was distributed as an ASP.Net 1.1 application. 
I had converted the old 1.1 source to compile under 2.0 and had used this configuration
for about three years.
</p>
        <p>
The biggest challenge was to convert the existing data files to work with the version. 
The DasBlog distribution comes with a conversion utility.  This worked fairly
well, but seems to trip up on some imbedded HTML in some of the posts.  About
four or five posts ended up with two copies in the new system.  I simply published
the converted files and then deleted the duplicates.
</p>
        <p>
Once the new system was operating the old permalinks were no longer working. 
I have a few posts that I was frequently getting referral notices by Google from the
system.  It took two or three weeks for Google to notice the changes, but they
did offer a cached version of the old page in the interim.
</p>
        <img width="0" height="0" src="http://fredwebs.com/blog/aggbug.ashx?id=a35141c2-b54a-4cb9-a7bb-87ba761ebcfc" />
      </div>
    </content>
  </entry>
  <entry>
    <title>The Future of LINQ</title>
    <link rel="alternate" type="text/html" href="http://fredwebs.com/blog/2008/12/24/TheFutureOfLINQ.aspx" />
    <id>http://fredwebs.com/blog/PermaLink,guid,89853fb7-9618-410b-85dc-ebad215f9f67.aspx</id>
    <published>2008-12-23T23:52:50.544625-05:00</published>
    <updated>2008-12-23T23:52:50.544625-05:00</updated>
    <category term="Entity Framework" label="Entity Framework" scheme="http://fredwebs.com/blog/CategoryView,category,EntityFramework.aspx" />
    <category term="LINQ" label="LINQ" scheme="http://fredwebs.com/blog/CategoryView,category,LINQ.aspx" />
    <category term="Microsoft" label="Microsoft" scheme="http://fredwebs.com/blog/CategoryView,category,Microsoft.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Maybe Microsoft has decided I don’t need to finish that book on LINQ that I bought
six months ago.  Rumors are flying that the new Entity Framework will eventually
replace LINQ.  Oh well, it’s just a quarter of the book that I read.  At
least I didn’t spend months writing a production application based on LINQ as some
have done.  The Redmond Developer News is a worthwhile magazine to read for serfs
of the Evil Empire.  This article breaks the news: <a href="http://reddevnews.com/news/article.aspx?editorialsid=10472">http://reddevnews.com/news/article.aspx?editorialsid=10472</a>.
</p>
        <img width="0" height="0" src="http://fredwebs.com/blog/aggbug.ashx?id=89853fb7-9618-410b-85dc-ebad215f9f67" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Silverlight Session Notes from the Atlanta Code Camp 2008</title>
    <link rel="alternate" type="text/html" href="http://fredwebs.com/blog/2008/04/18/SilverlightSessionNotesFromTheAtlantaCodeCamp2008.aspx" />
    <id>http://fredwebs.com/blog/PermaLink,guid,e5f99624-06db-4466-9c0f-d0acab4f3a1b.aspx</id>
    <published>2008-04-18T17:11:55-04:00</published>
    <updated>2008-04-18T17:11:58.960125-04:00</updated>
    <category term="ASP.Net" label="ASP.Net" scheme="http://fredwebs.com/blog/CategoryView,category,ASPNet.aspx" />
    <category term="Silverlight" label="Silverlight" scheme="http://fredwebs.com/blog/CategoryView,category,Silverlight.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
On Saturday, March 29, I attended the Atlanta Code Camp.  Last year I skipped
around to get an overview of a lot of different areas.  This year I decided to
concentrate on one of the eight offered tracks, Silverlight.  I wanted a deeper
knowledge of one subject, and I haven't got around to reading the Silverlight 1.0
book I bought a few months ago. 
</p>
        <p>
The following is a summary of my notes from the sessions.  Any errors are probably
mine during transcription.  Some parts will be fragmented and maybe only make
sense to me. 
<br /><br /><table cellspacing="0" cellpadding="2" border="0"><tbody><tr><td valign="top" colspan="2">
 <strong>1. Introducing Silverlight 2.0</strong></td></tr><tr><td valign="top" width="10">
 </td><td valign="top">
Corey Schuman - <a href="http://simplesilverlight.wordpress.com">http://simplesilverlight.wordpress.com</a></td></tr><tr><td valign="top" width="10">
 </td><td valign="top">
What’s new in Silverlight 2.0: Controls, uses of Silverlight, animations, connection
to data sources.</td></tr><tr><td valign="top" width="10">
 </td><td valign="top"><p>
Version 2.0 can consume web services, and importantly <strong>ALL</strong> calls are
asynchronous.
</p><p>
The XAP file is like the Flash SWF file, it is a zip file of all the DLL's.
</p><p>
In IIS must have XAP registered as a MIME type.
</p><p>
The BCL is the Base Class Library.  The isolated store will hold up to 1 MB,
and you can ask the end user for more up to 10 MB.
</p><p>
The Silverlight List Box can be used as a Control Container.  For beginners,
Corey suggested the introductory series by Scott Guthrie which can be found <a href="http://weblogs.asp.net/scottgu/archive/2008/02/22/first-look-at-silverlight-2.aspx">here</a>.  
</p></td></tr><tr><td colspan="2">
 </td></tr><tr><td valign="top" colspan="2"><strong>2. Using Blend 2.0 for Silverlight / Consuming Data with Silverlight 2.0</strong></td></tr><tr><td valign="top" width="10">
 </td><td valign="top">
Shawn Wildermuth- <a href="http://adoguy.com">http://adoguy.com</a></td></tr><tr><td valign="top" width="10">
 </td><td valign="top"><p>
An overview of Expression Blend 2.5 for Silverlight developers was given by Shawn. 
The current beta release has several bugs, it will crash on you.  One nice thing
is that Visual Studio 2008 and Blend use the same solution file.
</p><p>
Shawn continued with an overview of consuming data with Silverlight.  
</p><p>
There is no ADO in Silverlight, but there is full support for LINQ to Objects and
LINQ to XML.  Beware that LINQ projections have a bug.
</p><p>
The XDocument and the XMLDocument classes are available.  XMLDocument has a smaller
footprint, but does not support XPath.  You can use XMLReader but it is difficult
to work with.  Shaped results should be changed to simple types.
</p><p>
Silverlight tries to restrict you to calling a web service in the current domain only. 
To complicate things, the client configuration is not read in the 2.0 Beta.
</p><p>
As stated in the first session, the asynchronous is used with Binding, EndPoint, and
Proxy Classes.  If you are using the Visual Studio developer, a fixed port number
is useful, as are observable collections.  The state service SOAP client uses
a Sync call and completed Events.  When using WCF, you have a lot more configuration
items to set.  The query-able end points should develop shape data themselves.
</p><p>
ADO.Net Data Services, AKA Astoria, exposes data over HTTP(S) using URI syntax and
a REST interface.  The LINQ support hides REST, it is not available now but there
is a Silverlight 2 library in the works.  The REST functions Get, Post, Put,
and Delete do match the primary database CRUD functions.
</p><p>
For security cross domain calls  require permission.  The policy file "accesspolicy.xml"
must be in the root of the server.  Usually this is an all or nothing situation,
but you can use existing policies to allow and grant.
</p><p>
Only TCP sockets are allowed and are based on the platform (i.e. Winsock).  You
can only connect to the local machine by "localhost".  The Beta 1 has only socket
testing only, and on a small port range.
</p><p>
In the final session Shawn gave a brief overview of the DeepZoom composer and how
to use a DeepZoom image in your Silverlight 2 application. 
</p></td></tr><tr><td valign="top" width="10">
 </td><td valign="top">
Desc</td></tr><tr><td colspan="2">
 </td></tr><tr><td valign="top" colspan="2">
3<strong>. Real World Silverlight Tips and Tricks</strong></td></tr><tr><td valign="top" width="10">
 </td><td valign="top">
Steve Porter and Keith Rome - <a href="http://www.wintellect.com/cs/blogs/sporter">http://www.wintellect.com/cs/blogs/sporter</a>, <a href="http://www.mindfusioncorp.com/weblog">http://www.mindfusioncorp.com/weblog</a></td></tr><tr><td valign="top" width="10">
 </td><td valign="top">
Various Silverlight 1.0 and 2.0 tips and tricks that have been used on real projects. 
</td></tr><tr><td valign="top" width="10">
 </td><td valign="top">
Steve and Keith presented several interesting items in their presentation, among them
was the technique of using a storyboard as a timer.  The source code for these
may be found at the authors weblogs.  
</td></tr><tr><td colspan="2">
 </td></tr></tbody></table><img width="0" height="0" src="http://fredwebs.com/blog/aggbug.ashx?id=e5f99624-06db-4466-9c0f-d0acab4f3a1b" /></p>
      </div>
    </content>
  </entry>
  <entry>
    <title>Winform Design Mode Rendering Error</title>
    <link rel="alternate" type="text/html" href="http://fredwebs.com/blog/2007/12/05/WinformDesignModeRenderingError.aspx" />
    <id>http://fredwebs.com/blog/PermaLink,guid,4d163c0d-3b09-49e5-bf54-b09f6e81023d.aspx</id>
    <published>2007-12-05T15:25:28.361-05:00</published>
    <updated>2007-12-06T13:33:53.314375-05:00</updated>
    <category term="Windows Controls" label="Windows Controls" scheme="http://fredwebs.com/blog/CategoryView,category,WindowsControls.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
We recently upgraded our main application to the latest version of the Infragistics
controls.  Everything converted, compiled, and ran fine.  However, when
you tried to open some forms in the Visual Studio designer, you got the message "The
path is not of a legal form".  Looking at the project for these forms, they had
invalid references to custom controls that used Infragistics controls.  I deleted
the references and added the newly compiled versions to eliminate the designer rendering
error.
</p>
        <p>
Since we do not remove the previous version of Infragistics the older controls are
found at run time.  
</p>
        <img width="0" height="0" src="http://fredwebs.com/blog/aggbug.ashx?id=4d163c0d-3b09-49e5-bf54-b09f6e81023d" />
      </div>
    </content>
  </entry>
  <entry>
    <title>Visual Studio 2005: Key not valid for use in specified state</title>
    <link rel="alternate" type="text/html" href="http://fredwebs.com/blog/2007/10/12/VisualStudio2005KeyNotValidForUseInSpecifiedState.aspx" />
    <id>http://fredwebs.com/blog/PermaLink,guid,aad4b677-8d2f-49e4-8519-ecf979a943d1.aspx</id>
    <published>2007-10-12T10:31:28.720375-04:00</published>
    <updated>2007-10-12T10:31:28.720375-04:00</updated>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
We have recently migrated all of our workstations to a different Windows domain at
our office.  Some folks were getting the following error when trying to
open a DataSet in Visual Studio 2005: 
</p>
        <p>
Key not valid for use in specified state 
</p>
        <p>
The problem is caused because of the change of your username from the old domain
to the new domain. This causes Visual Studio to not be able to properly decrypt
some its settings. 
</p>
        <p>
The fix is to rename/delete the following file: 
</p>
        <p>
C:\Documents and Settings\YOUR USERNAME\Application Data\Microsoft\VisualStudio\8.0\ServerExplorer\DefaultView.SEView 
</p>
        <p>
You will now have to add back all your databases to the Server Explorer toolbox (but
you only have to add them at a later time as you need them). 
</p>
        <p>
Thanks to Robert Stam for this tip.
</p>
        <img width="0" height="0" src="http://fredwebs.com/blog/aggbug.ashx?id=aad4b677-8d2f-49e4-8519-ecf979a943d1" />
      </div>
    </content>
  </entry>
  <entry>
    <title>.NET Unable to Sign Assemblies or Read WSE Keys in Windows Server 2003</title>
    <link rel="alternate" type="text/html" href="http://fredwebs.com/blog/2007/08/10/NETUnableToSignAssembliesOrReadWSEKeysInWindowsServer2003.aspx" />
    <id>http://fredwebs.com/blog/PermaLink,guid,e3cd6893-a15e-49e1-8d83-f8776faa2c8b.aspx</id>
    <published>2007-08-10T16:57:34.899875-04:00</published>
    <updated>2007-08-10T16:57:34.899875-04:00</updated>
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
Recently we tried to build an older version of a system that is hosted on Windows
2003 server.  Every project in the build would fail with Visual Studio unable
to sign the DLL.  Of course the DLL was not there in the target folder, but that
was not the problem.  The build had worked before we rebuilt the server.
</p>
        <p>
A Google search produced a suggestion to change the file permissions on:
</p>
        <blockquote>
          <p>
C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys
</p>
        </blockquote>
        <p>
We gave Administrators full access to the folders and were able to compile.  
</p>
        <p>
Just a couple of days earlier, I had to give IIS_WPG access to this folder in order
for a web service to be able to read the keys and decrypt a WSE message.  The
service had worked fine after I had installed it and given access to the key file
using the WSE key utility.  
</p>
        <p>
I noticed a pending Windows update icon was no longer in the system tray.  It
appears that update had tightened security on that folder.
</p>
        <img width="0" height="0" src="http://fredwebs.com/blog/aggbug.ashx?id=e3cd6893-a15e-49e1-8d83-f8776faa2c8b" />
      </div>
    </content>
  </entry>
  <entry>
    <title>New Microsoft Tool for Deploying SQL Server</title>
    <link rel="alternate" type="text/html" href="http://fredwebs.com/blog/2007/03/28/NewMicrosoftToolForDeployingSQLServer.aspx" />
    <id>http://fredwebs.com/blog/PermaLink,guid,d8aa6503-cf3d-4f8c-b63a-6041611735a0.aspx</id>
    <published>2007-03-28T15:49:43.01-05:00</published>
    <updated>2007-03-28T15:51:54.7264972-05:00</updated>
    <category term="SQL Server" label="SQL Server" scheme="http://fredwebs.com/blog/CategoryView,category,SQLServer.aspx" />
    <category term="Deployment" label="Deployment" scheme="http://fredwebs.com/blog/CategoryView,category,Deployment.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
A new tool from Microsoft creates a single SQL file with both schema and
data creation commands, and works with 2000 and 2005. Read about it at <a title="SQL Server Deployment" href="http://weblogs.asp.net/scottgu/archive/2006/12/22/recipe-deploying-a-sql-database-to-a-remote-hosting-environment-part-1.aspx" target="_blank">Scott
Guthrie's blog</a>.
</p>
        <img width="0" height="0" src="http://fredwebs.com/blog/aggbug.ashx?id=d8aa6503-cf3d-4f8c-b63a-6041611735a0" />
      </div>
    </content>
  </entry>
  <entry>
    <title>ASP.Net Scroll on Post Back</title>
    <link rel="alternate" type="text/html" href="http://fredwebs.com/blog/2007/03/26/ASPNetScrollOnPostBack.aspx" />
    <id>http://fredwebs.com/blog/PermaLink,guid,2519a2f7-4a09-4238-8c2e-15971279c767.aspx</id>
    <published>2007-03-26T11:57:39.129-05:00</published>
    <updated>2007-03-28T15:53:02.3814482-05:00</updated>
    <category term="ASP.Net Controls" label="ASP.Net Controls" scheme="http://fredwebs.com/blog/CategoryView,category,ASPNetControls.aspx" />
    <category term="ASP.Net" label="ASP.Net" scheme="http://fredwebs.com/blog/CategoryView,category,ASPNet.aspx" />
    <category term="Javascript" label="Javascript" scheme="http://fredwebs.com/blog/CategoryView,category,Javascript.aspx" />
    <content type="xhtml">
      <div xmlns="http://www.w3.org/1999/xhtml">
        <p>
A recent project I've been working on is a knowledge base with dynamic
data structures.  As such, all of the controls placed on the update page are
dynamically created at runtime.  
</p>
        <p>
There is a drop down list for country and state, with the country list causing a post
back to fill the state list.  We needed the page to scroll back to the country
list after postback to relieve the user of having to scroll down two pages.  
</p>
        <p>
It didn't take much research to find the Page directive <font color="#ff0000">MaintainScrollPositionOnPostback</font><font color="#0000ff">="true".  </font><font color="#000000">While
this did get the page to scroll back to the drop down list, it also caused the page
to scroll back to the submit button when there was a validation error (all done on
the server side).  Hey, no problem, I'll just set that directive programatically
only when the post back is caused by that drop down list.</font></p>
        <p>
I found a nice article by Peter Bromberg on a way to determine the control that causes a
post back at <a title="http://www.eggheadcafe.com/articles/20050609.asp" href="http://www.eggheadcafe.com/articles/20050609.asp">http://www.eggheadcafe.com/articles/20050609.asp</a>. 
I got null exceptions when trying to return the control, so I changed the code slightly
to just return a string that describes the type of control.
</p>
        <p>
But more null exceptions awaited me when I tried to set the scroll back directive
from the drop down list call back function.  Apparently this was also related
to the dynamic nature of the page.  I decided to abandon the page directive and
to wade into Javascript.
</p>
        <p>
An article at ASP.Net magazine by Brad McCabe, <a title="http://www.aspnetpro.com/NewsletterArticle/2003/09/asp200309bm_l/asp200309bm_l.asp" href="http://www.aspnetpro.com/NewsletterArticle/2003/09/asp200309bm_l/asp200309bm_l.asp">http://www.aspnetpro.com/NewsletterArticle/2003/09/asp200309bm_l/asp200309bm_l.asp</a> got 
me started in the right direction.  The functions presented would save the scroll
position in a hidden field, and that field would later be used to set the scroll position. 
I converted the functions to C# and implemented them in my Page.OnInit function. 
After getting all the Javascript errors resolved (always a chore for me), the page refused
to scroll on post back.
</p>
        <p>
Using a neat Javascript trace utility from <a title="http://www.interlogy.com/~cigdem/trace/" href="http://www.interlogy.com/~cigdem/trace/">http://www.interlogy.com/~cigdem/trace/</a> I
was able to determine that "theBody.scrollTop", which I translated as "document.body.scrollTop",
was not returning anything.  So I was saving nothing to the hidden control.
</p>
        <p>
Looking further I found a set of Javascript functions by "Tigra" at <a title="http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html" href="http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html">http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html</a> that
would find the x or y scroll postion, and the height and width of the window. 
The article also has a great cross reference table for different browsers and the
window/scroll functions supported by each.
</p>
        <p>
I only needed the y scroll function, and used a call to it to replace the document.page.scrollTop
property.  Now Tracer was confirming that I was saving the correct scroll position,
but alas the page did not scroll back.  After a little more debugging I
determined the page would never scroll by setting the document.body.scrollTop in this
situation since this is just a property you are setting.  Something else would
have to read that value to set the scroll.  I had no idea what that might be
since Javascript is not my strong point.  
</p>
        <p>
But there is a scroll function, and by calling scroll(0, [saved y value]) I was able
to finally get the page to scroll back only to the drop down list.
</p>
        <p>
          <strong>The post back control function, in App_Data/Global.asax.cs:</strong>
        </p>
        <p>
    <span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,255)">static</span><span style="COLOR: rgb(0,0,255)">string</span> GetPostBackControlType(System.Web.UI.<span style="COLOR: rgb(0,128,128)">Page</span> page)<br />
    {<br />
        <span style="COLOR: rgb(0,0,255)">string</span> objectType
= <span style="COLOR: rgb(0,0,255)">string</span>.Empty;<br />
        <span style="COLOR: rgb(0,128,128)">Control</span> control
= <span style="COLOR: rgb(0,0,255)">null</span>;<br />
        <span style="COLOR: rgb(0,0,255)">string</span> ctrlname
= page.Request.Params[<span style="COLOR: rgb(128,0,0)">"__EVENTTARGET"</span>];<br /><br />
        <span style="COLOR: rgb(0,0,255)">if</span> (ctrlname
!= <span style="COLOR: rgb(0,0,255)">null</span> &amp;&amp; ctrlname != <span style="COLOR: rgb(0,128,128)">String</span>.Empty)<br />
        {<br />
            control = page.FindControl(ctrlname);<br />
        }<br />
          <span style="COLOR: rgb(0,128,0)">//
if __EVENTTARGET is null, the control is a button type and we need to<br /></span>          <span style="COLOR: rgb(0,128,0)">//
iterate over the form collection to find it<br /></span>        <span style="COLOR: rgb(0,0,255)">else<br /></span>        {<br />
            <span style="COLOR: rgb(0,0,255)">string</span> ctrlStr=<span style="COLOR: rgb(0,128,128)">String</span>.Empty;<br />
            <span style="COLOR: rgb(0,128,128)">Control</span> c=<span style="COLOR: rgb(0,0,255)">null</span>;<br />
            
<br />
            <span style="COLOR: rgb(0,0,255)">foreach</span> (<span style="COLOR: rgb(0,0,255)">string</span> ctl <span style="COLOR: rgb(0,0,255)">in</span> page.Request.Form)<br />
            {<br />
                <span style="COLOR: rgb(0,128,0)">//
handle ImageButton controls ...<br /></span>                <span style="COLOR: rgb(0,0,255)">if</span> (ctl.EndsWith(<span style="COLOR: rgb(128,0,0)">".x"</span>)
|| ctl.EndsWith(<span style="COLOR: rgb(128,0,0)">".y"</span>))<br />
               
{<br />
                   
ctrlStr = ctl.Substring(0,ctl.Length-2);<br />
                   
c= page.FindControl(ctrlStr);<br />
               
}<br />
                <span style="COLOR: rgb(0,0,255)">else<br /></span>               
{<br />
                   
c = page.FindControl(ctl);<br />
               
}<br />
                <span style="COLOR: rgb(0,0,255)">if</span> (c <span style="COLOR: rgb(0,0,255)">is</span> System.Web.UI.WebControls.<span style="COLOR: rgb(0,128,128)">Button</span> || 
<br />
                  
c <span style="COLOR: rgb(0,0,255)">is</span> System.Web.UI.WebControls.<span style="COLOR: rgb(0,128,128)">ImageButton</span>)<br />
               
{<br />
                   
control = c;<br />
                    <span style="COLOR: rgb(0,0,255)">break</span>;<br />
               
}<br />
            }<br />
        }<br /><br />
        <span style="COLOR: rgb(0,0,255)">if</span> (control
!= <span style="COLOR: rgb(0,0,255)">null</span>)<br />
        {<br />
            objectType = control.GetType().ToString();<br />
        }<br /><br />
        <span style="COLOR: rgb(0,0,255)">return</span> objectType;<br /><br />
    }  
</p>
        <p>
          <strong>The Javascript placed in the body of the aspx page:</strong>
        </p>
        <p>
    <span style="COLOR: rgb(0,0,255)">&lt;</span><span style="COLOR: rgb(128,0,0)">script</span><span style="COLOR: rgb(255,0,0)">type</span><span style="COLOR: rgb(0,0,255)">="text/javascript"</span><span style="COLOR: rgb(255,0,0)">language</span><span style="COLOR: rgb(0,0,255)">="javascript"&gt;<br /></span>        <br />
       <span style="COLOR: rgb(0,0,255)">function</span> SaveScrollLocation
() {<br />
            <span style="COLOR: rgb(0,128,0)">//trace('Scroll
Top = ' + f_scrollTop());<br /></span>            window.document.forms[0].__SCROLLLOC.value
= f_scrollTop();<br />
        }<br />
        window.document.body.onscroll=SaveScrollLocation;<br /><br />
       <span style="COLOR: rgb(0,0,255)">function</span> f_scrollTop()
{<br />
            <span style="COLOR: rgb(0,0,255)">return</span> f_filterResults
(<br />
               
window.pageYOffset ? window.pageYOffset : 0,<br />
               
document.documentElement ? document.documentElement.scrollTop : 0,<br />
               
document.body ? document.body.scrollTop : 0);<br />
        }<br /><br />
       <span style="COLOR: rgb(0,0,255)">function</span> f_filterResults(n_win,
n_docel, n_body) {<br />
            <span style="COLOR: rgb(0,0,255)">var</span> n_result
= n_win ? n_win : 0;<br />
            <span style="COLOR: rgb(0,0,255)">if</span> (n_docel
&amp;&amp; (!n_result || (n_result &gt; n_docel)))<br />
               
n_result = n_docel;<br />
            <span style="COLOR: rgb(0,0,255)">return</span> n_body
&amp;&amp; (!n_result || (n_result &gt; n_body)) ? n_body : n_result;<br />
        }<br />
    <span style="COLOR: rgb(0,0,255)">&lt;/</span><span style="COLOR: rgb(128,0,0)">script</span><span style="COLOR: rgb(0,0,255)">&gt;<br /></span></p>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
          <strong>The C# snippit placed in the Page OnInit function:</strong>
        </p>
        <p>
            <span style="COLOR: rgb(0,128,0)">//
hidden field to store scroll location<br /></span>            Page.ClientScript.RegisterHiddenField(<span style="COLOR: rgb(128,0,0)">"__SCROLLLOC"</span>, <span style="COLOR: rgb(128,0,0)">"0"</span>);<br /><br />
            <span style="COLOR: rgb(0,0,255)">if</span> (Page.IsPostBack)<br />
            {<br />
                <span style="COLOR: rgb(0,0,255)">string</span> ctrlType
= <span style="COLOR: rgb(0,128,128)">Global</span>.GetPostBackControlType(<span style="COLOR: rgb(0,0,255)">this</span>);<br /><br />
                <span style="COLOR: rgb(0,0,255)">if</span> (ctrlType.Contains(<span style="COLOR: rgb(128,0,0)">"DropDownList"</span>))<br />
               
{<br />
                    <span style="COLOR: rgb(0,128,0)">//
Keep scroll at the country drop down list<br /></span>                   
SetScrollLocation();<br />
               
}<br />
            }<br /></p>
        <p>
          <strong>The C# function to Set the Scroll Location:</strong>
        </p>
        <p>
    <span style="COLOR: rgb(0,0,255)">private</span><span style="COLOR: rgb(0,0,255)">void</span> SetScrollLocation()<br />
    {<br />
        <span style="COLOR: rgb(0,128,128)">StringBuilder</span> jsSB
= <span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,128,128)">StringBuilder</span>();<br /><br />
        jsSB.Append(<span style="COLOR: rgb(128,0,0)">"&lt;script
language='javascript'&gt;"</span>);<br />
        jsSB.Append(<span style="COLOR: rgb(128,0,0)">"function
SetScrollLocation () {"</span>);<br />
        jsSB.Append(<span style="COLOR: rgb(128,0,0)">" 
scroll(0,"</span> + Request[<span style="COLOR: rgb(128,0,0)">"__SCROLLLOC"</span>]
+ <span style="COLOR: rgb(128,0,0)">");"</span>);<br />
        jsSB.Append(<span style="COLOR: rgb(128,0,0)">"}"</span>);<br />
        jsSB.Append(<span style="COLOR: rgb(128,0,0)">"window.document.body.onload=SetScrollLocation;"</span>);<br />
        jsSB.Append(<span style="COLOR: rgb(128,0,0)">"&lt;/script&gt;"</span>);<br />
        
<br />
        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), <span style="COLOR: rgb(128,0,0)">"setScroll"</span>,
jsSB.ToString());<br /><br />
    }<br /></p>
        <a href="http://11011.net/software/vspaste">
        </a>
        <p>
While this implementation only acts on the DropDownList, you could easily extend it
to different controls or different dropdowns by returning the ID of the control causing
the postback.
</p>
        <img width="0" height="0" src="http://fredwebs.com/blog/aggbug.ashx?id=2519a2f7-4a09-4238-8c2e-15971279c767" />
      </div>
    </content>
  </entry>
</feed>