How to set the windows path in Windows 7

 

How to set the path in Windows 7.

Goal:

Setting the windows command path in Windows 7

Additional information:

Modifying the path statement will enable an MS-DOS window opened in Microsoft Windows as well as older programs to locate files that may be required to run the program.

In the old MS-DOS environment we used the PATH= command, located in the autoexec.bat file. Additional information about the MS-DOS path command that is still usable in Windows 2000 and Windows XP can be found on our path command page, additional information about the MS-DOS command can be found on our set command page.

See our dictionary path definition for additional information about this term and related definitions.

Answer:

The path is now managed by Windows 7 and not the autoexec.bat or autoexec.nt files. To change the system environment variables, follow the below steps.

  1. From the desktop, right-click My Computer and click Properties.
  2. In the System Properties window, click on the Advanced tab.
  3. In the Advanced section, click the Environment Variables button.
  4. Finally, in the Environment Variables window (as shown below), highlight the Path variable in the Systems Variable section and click the Edit button. Add or modify the path lines with the paths you wish the computer to access. Each different directory is separated with a semicolon as shown below.

    C:\Program Files;C:\Winnt;C:\Winnt\System32

Windows enviromental path settings

Do I have a 32-bit or 64-bit processor?

How to check what kind of processor you have (CPU) and what operating system can I run on it?

An X64 has a 64 bit microprocessor, whereas an X86, derived from the old 8086 PC, has a 32 bit microprocessor. A 32 bit machine and/or OS (operating system) is limited to about 3.55GB of memory, and an X64 is limited to about 17,179,869,184 gigabytes, 17,179,869 terabytes, or about 16 exabytes of RAM. Also a 32-bit CPU cannot run an 64-bit OS.

So, how to check your CPU:

Since you cannot run WIndows7-64x on a 32-bit machine lets look at windows 7.  From the Start icon on the toolbar select Control Panel. Look for Hardware and SOund and select View devices and printers. Double-click your computer (will be labeled with your machine name). A Properties window pops-up with two tabs, select the Hardware tab. Look for a name starting with ACPI, with Type of Computer. If it says ACPI x64-based PC you know you have a 64-bit machine, CONGRATULATIONS! You can now install a 64-bit OS like Vista-64 or Windows7-64 and run any of your old software as the new 64-bit OS "knows" (is compatible) how to run the 32-bit apps.

What about memory?

If you want to install more than 4GB or RAM you will need to have a 64-bit CPU and also run a 64-bit OS otherwise you are wasting your money.

How to stop and prompt user when closing browser

Scenario:

For some reason you want to stop the user from closing the browser window or from redirecting away from the current page, based on some condition.


The solution:

window.onbeforeunload = function(event) {
            return true;
        }

This will prompt you for input (like the JavaScript confirm pop-up menu). There is no way to override the text though.

Some concerns:
This works great but it may not be what you want all the time, as no matter if you click a hyperlink, hit submit, etc will prompt the user, which. So here is an example where when any input value on the screen has changed, I want to prompt the user only then and also only if the user decides to redirect from the page. It should not prompt the user when I try and save/delete or update the page:

var dataUpdated = false;

$(document).ready(function() {
    SetupChangeEventOnAllInputElementsAndSetGlobalFlag();
})

function SetupChangeEventOnAllInputElementsAndSetGlobalFlag() {
    $(':input').change(function() {
        dataUpdated = true;

        window.onbeforeunload = function(evt) {

            var e = e || window.event;

            // For IE and Firefox
            if (e) {
                if (DetermineSubmit(evt) == true)
                    return;
                else
                    e.returnValue = 'You have not saved your changes - OK to ignore or Cancel to remain on this page?';
            }
            else {
                // For Safari
                if (DetermineSubmit(evt) == true)
                    return
                else
                    return 'You have not saved your changes - OK to ignore or Cancel to remain on this page?';
            }
        }

    });

}

//Determine if the original event is a submit button/control that triggered the window unload
function DetermineSubmit(evt) {
    if ($(evt.explicitOriginalTarget).is(':submit')) {
        return true;
    }
   
    return false;
}

jQuery disable button intercepts Request Object

Scenario: Hijack all my save buttons via the script below to override the value, from Save to Saving...., and then also disabling the button so they cannot hit it 1000 times.

$(document).ready(function() {
   form.find(':submit').each(function() {
      $(this).attr("disabled", "disabled").val("Saving....");
   });
});

The Issue: I have several submit type buttons on the page, like Save, Sand and Proceed, Delete, etc, so I use the Request.Form object to see what button was pressed to decide what to do. Well, the disable of the button by jQuery removes it from the Reuquest stream, even though it is only disabled after the click event has occurred, how strange.

The Solution: I don't know what the solution is other than removing the disable as below. Any ideas?
$(document).ready(function() {
   form.find(':submit').each(function() {
      $(this).val("Saving....");
   });
});

Why does F10 (continue) in Visual Studio not work?

Scenario:

I'm debugging a (web) project in Visual Studio 2008. It is breaking and the first break point only, and thereafter when i hit F10 it ignores and subsequent break points and runs all the way through. Why is this happening? Couple of pointers before we discuss the solution

  • I have tried 'clean solution'.
  • Other breakpoints sometimes(!) skipped, even in the same method
  • Make sure that you're in Debug mode not in Release.
  • There could be an exception while executing the instruction in question. Try enabling all exceptions to break into debugger and check.
The solution may be:

Tools -> Options -> Debugging -> General -> Un-check off Enable Just My Code.

Intercept a form submit with jQuery and prevent or allow submission

Goal: Intercept a form submit, find out what submit button was clicked/invoked and decide to prevent the submission or continue to submit.

Solution:
$(document).ready(function() {
    $("form").submit(function(e) {
        if (e.originalEvent.explicitOriginalTarget.id == "myButton") {
            if (some status is true continue to submit the form)
                return true;
                //If the status above is false continue to prompt the user if they want to submit or not
            var ok = confirm('Do you really want to save your data?');
            if (ok) {               
                return true;
            }
            else {
                //Prevent the submit event and remain on the screen
                e.preventDefault();
                return false;
            }
        }
    });

    return;
});

Prevent repeated clicks on submit button

Scenario: The user wants to save something and hits the Save button (type=submit). The event performs an Ajax call to send the request to the server. The user, being unaware or not sure if their request is being processed or if they clicked the Save button properly, click it again, and again, causing several Ajax requests, which could be a real problem, if the update is to, for example, transfer funds to your ex-girlfriend's account

The solution: Prevent the user from being able to click the Save button or to when they do to ignore it.

$(document).ready(function() {
    $("form").submit(function(e) {
        if ($('form').valid()) {
            $(':submit', this).each(function() {
                if ($(this).attr('value') == 'Save') {
                    $(this).attr("disabled", "disabled").val("Saving....");
                }
            });
        }
    });
});


Couple of pointers:
  • The button being pressed is of type submit
  • The attr of the button gets disabled so the user cannot hit it again and again, and since the form is submitted there is no need for enabling it again.
  • In this example I have also overridden the value of the button to indicate that the form is being saved
  • In this example all submit buttons are impacted ($(':submit', this))
If you want to target only a specific button:

$(document).ready(function() {
    $("#myButton").submit(function(e) {
        $('#myButton', this).attr("disabled", "disabled").val("Processing....");
    });
});



Oops, this does not work!!!!!!!!!!!!!!!!

The reason being is that the submit action is attached to the form not the "myButton". In order to perform the above and find out which button was pressed and take appropriate action do:

    $("form").submit(function(e) {
        if (e.originalEvent.explicitOriginalTarget.id == "myButton") {
            //Do something
        }

    });

jQuery AutoComplete in ASP.NET MVC Framework

Goal:

jQuery AutoComplete in ASP.NET MVC Framework with callback to customize result


Platform/Environment:

  • Asp.Net Mvc version 1
  • jQuery 1.3.2
  • Autocomplete - jQuery plugin 1.0.2

Quick Solution:


Here I am simply returning a list of account names:

    $('#Name').autocomplete(
        $('#ajaxListMatchingAccountNamesUrl').val(), { delay: 10, minChars: 3, matchSubset: 1, matchContains: 1, cacheLength: 10, autoFill: true, mustMatch: false, selectFirst: true, max: 15 }
    );

ajaxListMatchingAccountNamesUrl - this is a hidden input control in my master page that contains the url that I set as follows so as to allow the Mvc framework to set it dynamically:

<input id="ajaxListMatchingAccountNamesUrl" type="hidden" value="<%=Url.RouteUrl(new {controller = "Account", Action = "GetMatchingAccounts"})%>" />

Here is the C# controller action:

        [AcceptVerbs(HttpVerbs.Get)]
        public string GetMatchingAccounts(string q)
        {
            if (String.IsNullOrEmpty(q))
                return null;

            var sb = new StringBuilder();
            foreach (AccountNameIdDTO dto in _accountRepository.SearchForAccountsStartingWithNameSuffixKey(q))
            {
                sb.AppendLine(dto.Name);
            }
            return sb.ToString();
        }

Complex Solution:

A situation where my account names may be the same for different acounts. In this scenario I let the server-side action append the unique ID to the name, surrounded by brackets: My Account Name (23). This way when the user selects the account, I store the name in the textbox and the ID is parsed out and stored in a protected/readonly textbox.

    var $accountMaintenanceWrapper = $('div#AccountMaintenanceWrapper');
    $accountMaintenanceWrapper.find("#MasterAccount").autocomplete(
        $('#ajaxListMatchingAccountNamesWithIdSuffixUrl').val(),
        {
            delay:10,
            minChars:3,
            matchSubset:1,
            matchContains:1,
            cacheLength:10,
            autoFill:true,
            mustMatch: false,
            selectFirst : true,
            max: 15,
            formatResult: function(row, i, total) //this is the actual value that will be placed inside the textbox
            {
                //Parse out the ID suffix in brackets and place only the account name itself into the textbox for the name
                $accountMaintenanceWrapper.find('#MasterAccountId').val(i.substring(i.indexOf('(')+1,i.indexOf(')')));
                return i.substring(0,i.indexOf('('));
            }
        }
    );
   
    $accountMaintenanceWrapper.find("#MasterAccount").result(SetupCallBackForMasterAccount).next().click(function() {
            $(this).prev().search();
    });
   
    //When the auto complete textbox is empty, delete the key code from the text
    $accountMaintenanceWrapper.find("#MasterAccount").bind('keyup',function() {
        if ($(this).val() == '')
        {
            $accountMaintenanceWrapper.find('#MasterAccountId').val('')
        }
    });


//This function parses the matched auto complete value's suffix key (in between parenthesis)
function SetupCallBackForMasterAccount(event, data, formatted) {
    $('#MasterAccountId').val( !data ? " " : formatted.substring(formatted.indexOf('(')+1,formatted.indexOf(')')));
}

Here is the C# code controller action:

        [AcceptVerbs(HttpVerbs.Get)]
        public string GetMatchingAgentsWithIdSuffix(string q)
        {
            if (String.IsNullOrEmpty(q))
                return null;

            var sb = new StringBuilder();
            foreach (AccountNameIdDTO dto in _accountRepository.SearchForAccountsStartingWithNameSuffixKey(q))
            {
                if ((Repository<IAccount>.Get(dto.Id) as Agency) != null)
                    sb.AppendLine(dto.Name + "(" + dto.Id + ")");
            }
            return sb.ToString();
        }


Couple of pointers:

  • $accountMaintenanceWrapper - I declare this variable as I am referencing this container several times and to speed performance let jQuery find it and set the reference only once.
  • MasterAccountId - this is the readonly textbox that will contain the value of the unique ID
  • MasterAccount - this is the textbox where the user enters the name of the account
  • minChars:3 - Starts the search after/on three characters
  • selectFirst : true - if the user does not click on the name and simply tabs out will select the first one

Browser engine performance related to JavaScript

Question: Which browser engine perform better when it comes to JavaScript?


Browsers tested:


  • Firefox version 3.5.2
  • IE8.0.6001.18702
  • Google Chrome 1.0.154

Results:


When it came to rendering a complex page with lots of jQuery client-side activity, they all performed well, but Google Chrome is definitely faster than Firefox as well as IE8. However, in one of the screens I loaded multiple grids (jqGrid) that each calls the server via Ajax asynchronously. The interesting result here is that IE8 outperforms Firefox and Chrome by an order of magnitude. It loaded the 5 grids visibly about twice as fast as both Firefox and Chrome, the last two performing visibly the same. Without getting in to too much technical jargon, IE8 obviously performs some kind of parallel call whereas the other two rendering engines perform the different Ajax calls in sequence. When it comes to design and development work requiring WYSIWYG results, Firefox is king with the Firebug, YSlow, CacheViewer, and other plug-ins. I can recommend Chrome when client-side performance is crucial to users, but Firefox is hard to beat when it comes to plug-in support, security, adherence to HTML and CSS standards compliance.

 

To put it into perspective here are some stats on the content rendered:

3429 DOM elements on the page!


doc (1) 63.5K    
js (2) 1532.3K    
css (2) 234.4K    
cssimage (25) 38.1K    
image (22) 33.1K

 


jqGrid hide columns but show when editing/adding

Issue:

I have a grid which I have what I can only describe as containing “Core” data and “Minor” data. What I'd like to be able to do is to show the Core data in the main grid view but to allow the user to add/edit/view the Core and Minor data when they open the relevant dialog.

In essence this would be like having hidden columns that were viewable/editable when the dialogs were opened with form editing/viewing.

The Minor data is only of interest to some users, so I don't want to show it in the main grid view and this would also help keep the grids width down and not have a long horizontal scroll.

Is this possible?

Short answer: YES it is very possible and very well supported in the jqGrid

Long answer:

Here is an example, it contains a lot but wanted to also show you some other tips that you may find helpful, see the explanation of the tip by matching the color with the colored comment at the end of this post.

 

        .jqGrid({
            url: listURL,
            postData: { accountId: $('fieldset#AccountDetails #Id').val() },
            datatype: “json”,
            colNames: ['Id', '', 'Name', 'First Name', 'Middle name', 'Last Name', 'Phone', 'Email', 'Activity', 'Title', 'Prefix', 'Suffix', 'Account Role', 'DM Role', 'DISC Profile', 'Notes'],
            colModel: [
                { name: 'Id', index: 'Id', width: 35, sortable: true, align: "center", resizable: false, hidden: false, editable: false, editoptions: { readonly: true, size: 0} },
                { name: 'EditUrl', index: '', width: 28, editable: false, sortable: false, align: "center", resizable: false },
                { name: 'FullNameUrl', index: 'FullNameUrl', width: 80, editable: false, sortable: true, align: "left", resizable: true, editrules: { edithidden: false} },
                { name: 'FirstName', index: 'FirstName', width: 40, editable: true, sortable: true, align: "left", resizable: true, hidden: true, editrules: { edithidden: true, required: true} },
                { name: 'MiddleName', index: 'MiddleName', width: 40, editable: true, sortable: true, align: "left", resizable: true, hidden: true, editrules: { edithidden: true} },
                { name: 'LastName', index: 'LastName', width: 40, editable: true, sortable: true, align: "left", resizable: true, hidden: true, editrules: { edithidden: true} },

                { name: 'PhoneNumber', index: 'PhoneNumber', width: 80, editable: false, sortable: false, align: "left", resizable: true },
                { name: 'Email', index: 'Email', width: 80, editable: false, sortable: false, align: "left", resizable: true },
                { name: 'ActivityStatus', index: 'ActivityStatus', width: 40, editable: true, sortable: true, align: "left", resizable: true, edittype: "select", editoptions: { value: allActivityStatuses }, editrules: { edithidden: true, required: true} },
                { name: 'Title', index: 'Title', width: 80, editable: true, sortable: true, align: "left", resizable: true },
                { name: 'Prefix', index: 'Prefix', width: 80, editable: true, sortable: true, align: "left", resizable: true, hidden: true, editrules: { edithidden: true} },
                { name: 'Suffix', index: 'Suffix', width: 80, editable: true, sortable: true, align: "left", resizable: true, hidden: true, editrules: { edithidden: true} },
               {name: 'ContactRoleNames', index: 'ContactRoleNames', width: 40, editable: true, hidden: true, hidedlg: true, edittype: "select", editoptions: { multiple: true, size: 4, value: allAccountRoles }, editrules: { edithidden: true, required: true} },
                { name: 'DMRole', index: 'DMRole', width: 30, editable: true, sortable: false, align: "center", resizable: false, edittype: "select", hidden: true, editoptions: { value: allDMRoles }, editrules: { edithidden: true, required: true} },
                { name: 'DISCProfile', index: 'DISCProfile', width: 30, editable: true, sortable: false, align: "center", resizable: false, edittype: "select", hidden: true, editoptions: { value: allDISCProfiles }, editrules: { edithidden: true, required: true} },
                { name: 'Notes', index: 'Notes', width: 85, editable: true, sortable: false, align: "left", resizable: true, edittype: "textarea", editoptions: { rows: "2", cols: "40"} }


            ],

To your question, I display the Full Name of the contact, but want to hide the full name when editing but show the FirstName, MiddleName and LastName when editing/adding. Notice the “hidden: true, editrules: { edithidden: true}” properties.

This EditUrl is visible in the grid, but its just an image hyperlink to another page and cannot be edited, hence, “editable: false

The DISCProfile column has a drop down box with dynamically loaded data: “editoptions: { value: allDISCProfiles }“. This data is retrieved before the grid is defined in the JavaScript file with:

var allDISCProfiles = $.ajax({ url: $('#ajaxAllDISCProfilesUrl').val(), async: false, success: function(data, result) { if (!result) alert('Failure to retrieve the DISC Profiles.'); } }).responseText;

 

Hope this helps