Navigation

Search

Categories

On this page

Winform Design Mode Rendering Error
Visual Studio 2005: Key not valid for use in specified state
.NET Unable to Sign Assemblies or Read WSE Keys in Windows Server 2003
New Microsoft Tool for Deploying SQL Server
ASP.Net Scroll on Post Back
Das Blog ASP.Net 2.0 Vanishing Content
Using WSE 2.0 in ASP.Net 2.0
Date Format Recognition in ASP.NET Controls
CSS and ASP.Net
New Hosting Provider

Archive

Blogroll

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

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 17
This Year: 2
This Month: 0
This Week: 0
Comments: 1

Sign In
Pick a theme:

# Wednesday, December 05, 2007
Wednesday, December 05, 2007 8:25:28 PM UTC ( Windows Controls )

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.

Since we do not remove the previous version of Infragistics the older controls are found at run time. 

Comments [0] | | # 
# Friday, October 12, 2007
Friday, October 12, 2007 2:31:28 PM UTC ( )

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:

Key not valid for use in specified state

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.

The fix is to rename/delete the following file:

C:\Documents and Settings\YOUR USERNAME\Application Data\Microsoft\VisualStudio\8.0\ServerExplorer\DefaultView.SEView

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).

Thanks to Robert Stam for this tip.

Comments [0] | | # 
# Friday, August 10, 2007
Friday, August 10, 2007 8:57:34 PM UTC ( )

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.

A Google search produced a suggestion to change the file permissions on:

C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys

We gave Administrators full access to the folders and were able to compile. 

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. 

I noticed a pending Windows update icon was no longer in the system tray.  It appears that update had tightened security on that folder.

Comments [0] | | # 
# Wednesday, March 28, 2007
Wednesday, March 28, 2007 8:49:43 PM UTC ( SQL Server | Deployment )

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 Scott Guthrie's blog.

Comments [0] | | # 
# Monday, March 26, 2007
Monday, March 26, 2007 4:57:39 PM UTC ( ASP.Net Controls | ASP.Net | Javascript )

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. 

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. 

It didn't take much research to find the Page directive MaintainScrollPositionOnPostback="true".  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.

I found a nice article by Peter Bromberg on a way to determine the control that causes a post back at http://www.eggheadcafe.com/articles/20050609.asp.  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.

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.

An article at ASP.Net magazine by Brad McCabe, http://www.aspnetpro.com/NewsletterArticle/2003/09/asp200309bm_l/asp200309bm_l.asp 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.

Using a neat Javascript trace utility from http://www.interlogy.com/~cigdem/trace/ 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.

Looking further I found a set of Javascript functions by "Tigra" at http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html 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.

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. 

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.

The post back control function, in App_Data/Global.asax.cs:

    public static string GetPostBackControlType(System.Web.UI.Page page)
    {
        string objectType = string.Empty;
        Control control = null;
        string ctrlname = page.Request.Params["__EVENTTARGET"];

        if (ctrlname != null && ctrlname != String.Empty)
        {
            control = page.FindControl(ctrlname);
        }
          // if __EVENTTARGET is null, the control is a button type and we need to
          // iterate over the form collection to find it
        else
        {
            string ctrlStr=String.Empty;
            Control c=null;
           
            foreach (string ctl in page.Request.Form)
            {
                // handle ImageButton controls ...
                if (ctl.EndsWith(".x") || ctl.EndsWith(".y"))
                {
                    ctrlStr = ctl.Substring(0,ctl.Length-2);
                    c= page.FindControl(ctrlStr);
                }
                else
                {
                    c = page.FindControl(ctl);
                }
                if (c is System.Web.UI.WebControls.Button ||
                   c is System.Web.UI.WebControls.ImageButton)
                {
                    control = c;
                    break;
                }
            }
        }

        if (control != null)
        {
            objectType = control.GetType().ToString();
        }

        return objectType;

    } 

The Javascript placed in the body of the aspx page:

    <script type="text/javascript" language="javascript">
        
       function SaveScrollLocation () {
            //trace('Scroll Top = ' + f_scrollTop());
            window.document.forms[0].__SCROLLLOC.value = f_scrollTop();
        }
        window.document.body.onscroll=SaveScrollLocation;

       function f_scrollTop() {
            return f_filterResults (
                window.pageYOffset ? window.pageYOffset : 0,
                document.documentElement ? document.documentElement.scrollTop : 0,
                document.body ? document.body.scrollTop : 0);
        }

       function f_filterResults(n_win, n_docel, n_body) {
            var n_result = n_win ? n_win : 0;
            if (n_docel && (!n_result || (n_result > n_docel)))
                n_result = n_docel;
            return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
        }
    </script>

The C# snippit placed in the Page OnInit function:

            // hidden field to store scroll location
            Page.ClientScript.RegisterHiddenField("__SCROLLLOC", "0");

            if (Page.IsPostBack)
            {
                string ctrlType = Global.GetPostBackControlType(this);

                if (ctrlType.Contains("DropDownList"))
                {
                    // Keep scroll at the country drop down list
                    SetScrollLocation();
                }
            }

The C# function to Set the Scroll Location:

    private void SetScrollLocation()
    {
        StringBuilder jsSB = new StringBuilder();

        jsSB.Append("<script language='javascript'>");
        jsSB.Append("function SetScrollLocation () {");
        jsSB.Append("  scroll(0," + Request["__SCROLLLOC"] + ");");
        jsSB.Append("}");
        jsSB.Append("window.document.body.onload=SetScrollLocation;");
        jsSB.Append("</script>");
       
        Page.ClientScript.RegisterClientScriptBlock(Page.GetType(), "setScroll", jsSB.ToString());

    }

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.

Comments [0] | | # 
# Monday, March 05, 2007
Monday, March 05, 2007 9:02:54 PM UTC ( ASP.Net | Das Blog )

I recently had all my entries disappear from this blog.  After reading about the problem at dasblog.us I extended the session timeout on the site.  It looks to me like the session expired during a lengthy editing session, and left the system in an unstable state.  I had to upload a new version of web.config to get my content to display once more. 

This entry was created using Widows Live Writer, which writes directly to the site and will avoid any session timeouts. 

Comments [0] | | # 
Monday, March 05, 2007 7:02:12 PM UTC ( ASP.Net | Web Services | WSE )

I was tasked with developing a web service for our development team that would mimick the operation of a client web service that has access limited by IP address. This target service was developed with WSE 2.0.  The encryption used in WSE 2.0 is different from that in 3.0.  Allthough some posts I read said you could change the encryption mode, I decided it would be less risky to adapt WSE 2.0 to ASP.NET 3.0. 

There are lots of sample programs for using WSE 3.0 in ASP.Net 2.0, but none using WSE 2.0. Here are a couple of things that I had to change in the Web.Config given in the sample projects that come with the WSE install:


<
security>
<
x509 storeLocation="LocalMachine" allowTestRoot="true" allowRevocationUrlRetrieval="false" verifyTrust="true"/>
<!--
Replaced UsernameSignCodeService with App_Code for using WSE 2.0 in VS2005!!!! -->
<
securityTokenManager type="EcsMockWebService.CustomUsernameTokenManager, App_Code" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" qname="wsse:UsernameToken" />
</
security>


<
webServices>
<
soapExtensionTypes>
<!--
group="0" removed from the end of the following line to use WSE 2.0 in ASP.Net 2.0 -->
<
add type="Microsoft.Web.Services2.WebServicesExtension, Microsoft.Web.Services2, Version=2.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" priority="1"/>
</
soapExtensionTypes>
</
webServices>

Comments [0] | | # 
# Monday, January 29, 2007
Monday, January 29, 2007 4:53:54 PM UTC ( ASP.Net Controls )
Validating alternate date formats in ASP.Net
Comments [0] | | # 
# Monday, January 15, 2007
Monday, January 15, 2007 4:25:30 PM UTC ( CSS - ASP.Net )
Getting ASP.Net to play pretty with CSS.
Comments [0] | | # 
# Wednesday, November 29, 2006
Wednesday, November 29, 2006 4:27:15 AM UTC ( Web Hosting )
New Web Hosting Service
Comments [0] | | #