Thursday, September 22, 2011

Replace .Net Validation Summary with jQuery UI dialog

This will replace the older looking .Net Validation Summary built-in JavaScript pop-up with a more modern looking jQuery UI dialog.  It works by hiding the real Validation Summary text, then shows it via a dialog by using a wrapper panel.

A new click event (in addition to your original one) is assigned to the submission button.  When the button is clicked, if .Net sets the Page_IsValid to false, then the dialog is triggered.  Otherwise the page submits like normal.

.Net Code

    <asp:Panel ID="panError" runat="server" CssClass="ui-state-error" Style="displaynone">
        <span class="ui-icon ui-icon-circle-close" style="margin0 7px 50px 0floatleft;">
        </span><span>
            <asp:ValidationSummary ID="summaryMain" EnableClientScript="true" ShowMessageBox="false"
                ShowSummary="true" runat="server" CssClass="ui-state-error-text" style="text-align:left" />
        </span>
    </asp:Panel>

JavaScript (jQuery) Code
    <script type="text/javascript">
        jQuery(document).ready(function () {
            $("#<%= this.btnSave.ClientID %>").click(function () {
                if (!Page_IsValid) {
                    $("#<%= this.panError.ClientID %>").dialog({
                        resizable: false,
                        width: 420,
                        modal: true,
                        buttons: {
                            'Close'function () {
                                $(this).dialog('close');
                            }
                        }
                    });
                }
            });
        });
    </script>

Friday, September 9, 2011

Using Linked Files in a Web Application Project

I was in need of a way to share JavaScript files, CSS, and other static files (i.e. non-compiled) between web application projects.  I continually maintained and updated the files on the main web project, but rarely kept up with the secondary project until it was absolutely necessary. 

This great find lets me use the Linked files feature of Visual Studio with Web Application projects.  By default the linked files are only copied to the /bin directory and not to the actual web application project structure for actually viewing the website.

http://consultingblogs.emc.com/jamesdawson/archive/2008/06/03/using-linked-files-with-web-application-projects.aspx

Monday, August 15, 2011

Unknown server tag 'asp:ScriptManager'

LiveJournal Tags:
This exception has popped up more than once for me, but the answer when searching for help is always the same.  Add the following to your web.config (or similar based on your version of .Net).
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
This simple solution of course is never the case for me.  If you have the above already in your web.config, the gist of the real problem is that your web.config is actually not loading into the current context due to some other error.
I thought I’d offer some steps I’ve used that seem to always fix the problem for me. 
LiveJournal Tags:
  1. If you are using Local IIS Server as your hosting server, switch to the built-in Visual Studio Development Server temporarily and see if the website loads normally.
    • If your website loads normally in the built-in web server;  sometimes Visual Studio botches the creation of the IIS virtual directory and application.  Check IIS admin to see if your settings are correct (or if the virtual directory even exists!).
  2. Try commenting out the entire script tag (<asp:ScriptManager ID="ScriptManager1" runat="server" />) and see if it reveals the real error.  Any other custom controls on the page may fail as well, so keep commenting out until you either see a different error or the page loads normally.
  3. Add the namespace mapping directly to the page.  This is a last resort, but sometimes necessary to just get by the problem.
    • <@ Register Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" TagPrefix="asp" %>



Monday, August 1, 2011

Manual Adobe Acrobat Reader Download

I get tired of searching for this every time I need it. 

You can manually download any version of Acrobat Reader at:

ftp://ftp.adobe.com/pub/adobe/reader/

Wednesday, July 20, 2011

Using jQuery UI Dialog as a confirmation box for an ASP.Net button

This will add a jQuery UI Dialog confirmation when clicking a button in asp.Net. This is a non-generic, one button <-> one dialog example.

The button:
    <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" CausesValidation="true" OnClientClick="jQuery('#confirmation').dialog('open'); return false;" />


 
The Dialog display div:
    <div id="confirmation" title="Submit Form?">
        <span class="ui-icon ui-icon-alert" style="margin0 7px 50px 0floatleft;"></span>
        <span>Are you sure you would like to submit this form?</span>
    </div>

The Javascript:
    <script type="text/javascript">
        jQuery(document).ready(function() {
            $('#confirmation').dialog({
                autoOpen: false,
                modal:true,
                buttons: {
                    "Submit"function() { $(this).dialog("close"); <%= Page.ClientScript.GetPostBackEventReference(this.btnSubmit, string.Empty) %>; },
                    "Cancel"function() { $(this).dialog("close"); }
                }
            });
         });
    </script>

NOTE:  As sisyphus has pointed out below, this does not call client side validation.  I rarely use this method for submitting anything requiring it, so it never occured to me to include it.   I'm including code that should allow client side validation to occur.  It's not tested, but I'm pretty sure it is accurate :)
 
The Javascript with Client Side Validation invoked:    
<script type="text/javascript">
        jQuery(document).ready(function() {
            $('#confirmation').dialog({
                autoOpen: false,
                modal:true,
                buttons: {
                    "Submit": function() { $(this).dialog("close"); if (Page_ClientValidate()) <%= Page.ClientScript.GetPostBackEventReference(this.btnSubmit, string.Empty) %>; },
                    "Cancel": function() { $(this).dialog("close"); }
                }
            });
         });
    </script>




Sunday, May 1, 2011

WP7 Error During Update: 801812C1 -- Device Unplugged

UPDATE:  This issue no longer seems to occur with the latest update to the Zune software (4.8.2345.0).

The original thread is located at: http://answers.microsoft.com/en-us/winphone/forum/wp7-sync/wp7-error-during-update-801812c1/478cd9d8-cb63-e011-8dfc-68b599b31bf5#_self




My Original Question:
I know exactly why it is happening, and this is the same problem I'm having with wireless sync.  All other functions between Zune and the phone are fine, as apparently they do not require the Zune or ZuneWireless device driver.

The WindowsPhone driver installation fails the same way on the initial, first try but then seems to complete normally every other time somehow.

The phone disconnects automatically before the Zune or Zune Wireless driver completely installs.  It takes upwards of 5 to 10 minutes before I get a driver installation failure with the "Device Unplugged" message.  I have no idea why it takes so long for the driver installation, but it's nothing I can seem to fix.

So:

  • Is there a way to update this wait timeout of the phone during driver installation to be indefinite or at least much longer?
  • Is there a way to manually install these drivers so they are ready to use upon the phone's connection?
Note:  There is no reason to post a link to http://support.microsoft.com/kb/2484484#801812C1 here as a potential answer.  The solution on that page has no impact on my problem.  It explains the issue I'm having, but the solution will not work because it assumes there was some error due to a non-repeatable problem.
My final response with a semi-answer after no help:
Sorry to see others having the same problem as me, but I knew it would come up.  The goal to fixing it is to reduce the time it takes to find the driver it is looking for.  It really has little to do with the phone or Zune, but instead actual Windows (at least in the fact that they apparently aren't going to update Zune to handle this situation, which I think they should).

If you are a semi-advanced user here are few things to try.  I managed to get mine to find the driver in time for about 1 out 5 tries by doing these things.  Once it finds the driver the first time, everything works smooth from then on.

Edit the Default Driver Search Location Registry Key
You will want to just pre-pend the Zune driver location to it.
Key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\DevicePath
Original Value:
%SystemRoot%\inf
New Value:
C:\Program Files\Zune\Drivers\Zune;%SystemRoot%\inf

Disable the Windows Update searching during driver installation

Note 1:  Make sure to notice you'll actually need to turn off two items (one in the steps and there is a Note in the heading to tell you about another one to turn off).
Note 2: If you are part of a real domain, you'll need to reconnect to that domain and reboot before the policy will be effective.  Otherwise, just reboot.

Wednesday, December 8, 2010

Delete Visual Studio Server Explorer Connections

The short, the file is located at C:\Users\<username>\AppData\Roaming\Microsoft\VisualStudio\10.0\ServerExplorer\DefaultView.SEView.  It is a plain XML file and can be edited by hand to remove the offending entries and is located in the Roaming sub-folder even if you are not on a roaming profile.

For more info, see the original article I found the location on.