Thursday 20 October 2016

Update progress in center of screen

Update proggress bar For Iphone   Click Here


Download the code sample


At the moment I'm working on making a web application we just developed more user friendly and more appealing to the end users.
The application uses a few ASP.NET Ajax controls so I was pretty surprised when the customer sent me an email saying that he liked all the dynamic loading and the fact that he could reorder "things" using drag&drop and saving them without waiting the page to reload, but it took him a while to understand was going on. The first time he clicked the button, and since nothing happened, he thought that something was going wrong, so he kept clicking on the button, an yet nothing happening.
The problem was that since all the Ajax interactions happen behind the scenes asynchronously, the user doesn't understand what's going on: sometimes the user doesn't need to know what's going on (like when you are just reloading some data), but when he presses a button he needs to know that he did the right thing and that something is happening. With the "old style" ASP.NET a postback would have been initiated, so it was obvious that something was happening, but how to do it using Ajax?

That is pretty easy to accomplish with ASP.NET: just drop in anUpdateProgress control and it will be displayed when an Ajax postback happens.
But, as default behavior, the UpdateProgress is displayed in the position where it is added to the page, so, if your page is longer than a scroll page, the indicator could not be visible: it has to be positioned relative to the browser window and not relative the html document.
At first I looked at how to hook into the script that displays the div in order to change the position via script, but while chatting with Daniela (which is an UIX and web designer) she said: "Why don't you just use the fixed positioning CSS attribute?"
And she was right, much easier than hooking into ASP.NET Ajax scripts. I definitely need to improve my CSS knowledge smile_regular.

Step 1 - Add an UpdateProgress control to the page

First thing you have to add an UpdateProgress to your ASP.NET page.
<asp:UpdateProgress ID="UpdateProgress1" runat="server"
                     DynamicLayout="false">
    <ProgressTemplate>
        <img src="Images/ajax-loader.gif" /> Loading ...
    </ProgressTemplate>
</asp:UpdateProgress>
You can put this code anywhere inside the page, but I suggest you put it at the end. I didn't specify any AssociatedUpdatePanelID because I want the loading indicator to appear for all the UpdatePanel I have on the page: if you want it only for some of them you have to set it.

Step 2 - Add CSS

 #UpdateProgress1 {
   background-color:#CF4342;
   color:#fff;
   top:0px;
   right:0px;
   position:fixed;
 }

#UpdateProgress1 img {
   vertical-align:middle;
   margin:2px;
 }

The trick is to set the position attribute to fixed: it will make the top and right dimensions relative to the browser window and not to its original position (as with relative) or to containing element (as with absolute).
This CSS will put the indicator on the top right corner of the window, as the Gmail indicator.

Step 3 - Add an activity indicator image

But we can do it even better then gmail, we could add a nice animated activity indicator. Last yearScottGu recommended a few websites to download some indicators from, and I really likedwww.ajaxload.info. This site dynamically generate an activity indicator for you, with the type and colors you prefer.
This is the animated gif I created to fit nicely into my UpdateProgress control: 
And this is how the final Gmail-like loading indicator looks like:
 Loading ...

Monday 17 October 2016

Remove a write-protected USB drive or SD card

Step 1 of 4:


How to erase a write-protected USB drive or SD card: Summary

To format a USB drive or SD card you may first need to remove the write protection, which is possible by tweaking commands in the Windows Registry. In this article we offer a step-by-step guide on how to erase a write-protected USB drive or SD card.

Step 2 of 4:


How to erase a write-protected USB drive or SD card: Step-by-step guide

Some SD cards and USB sticks have write protection switches. When enabled they prevent files from being deleted, or any new files being written to the device. It also stops you from accidentally formatting the card or stick.



Occasionally, you’ll find that an SD card or USB flash drive will refuse to format and Windows will tell you that it is write protected, even though there is no switch, or the switch is set correctly to allow the device to be written to.
Typically, you can read the files which are already stored on the drive, but you can't delete them (they sometimes seem to delete ok, but the next time you check, there they are again!).
Here are a couple of ways you can try to format the drive and remove the write protection. Bear in mind that there is no guarantee that they will work for you: your USB flash drive or SD card may be corrupt or physically broken and no utility or low-level formatting tool will make it work again. The only solution in this case is to buy a new drive. (See also:Recover deleted files for free: recover lost data.)

Step 3 of 4:


If you can’t find StorageDevicePolicies, you can try creating a key by right-clicking in the white space in the Control folder and choosing New -> Key and carefully entering the name.

Now double-click on the new key (folder) and right-click once again and choose New -> DWORD. Name it WriteProtect and set its value to 0. Click OK, exit Regedit and reboot your computer.
If this method doesn’t work, skip to the next step.

Step 4 of 4:



Removing write-protection using Diskpart

With your USB drive plugged in, launch a command prompt. Do this by searching for cmd.exe in the Start menu (or Start screen in Windows 8). In Windows XP, click Start then Run, and type cmd.exe in the box.


NOTE: you may need to run Cmd.exe with administrator privileges if you see an “access is denied” message.
To do that, right-click on the shortcut and choose Run as administrator. In Windows 8, simply choose Command prompt (admin).
Now, type the following, pressing Enter after each command:
diskpart
list disk
select disk x (where x is the number of your USB flash drive – use the capacity to work out which one it is)
attributes disk clear readonly
clean
create partition primary
format fs=fat32  (you can swap fat32 for ntfs if you only need to use the drive with Windows computers)
exit

Remove a write-protected USB drive or SD card

Step 1 of 4:


How to erase a write-protected USB drive or SD card: Summary

To format a USB drive or SD card you may first need to remove the write protection, which is possible by tweaking commands in the Windows Registry. In this article we offer a step-by-step guide on how to erase a write-protected USB drive or SD card.

Step 2 of 4:


How to erase a write-protected USB drive or SD card: Step-by-step guide

Some SD cards and USB sticks have write protection switches. When enabled they prevent files from being deleted, or any new files being written to the device. It also stops you from accidentally formatting the card or stick.



Occasionally, you’ll find that an SD card or USB flash drive will refuse to format and Windows will tell you that it is write protected, even though there is no switch, or the switch is set correctly to allow the device to be written to.
Typically, you can read the files which are already stored on the drive, but you can't delete them (they sometimes seem to delete ok, but the next time you check, there they are again!).
Here are a couple of ways you can try to format the drive and remove the write protection. Bear in mind that there is no guarantee that they will work for you: your USB flash drive or SD card may be corrupt or physically broken and no utility or low-level formatting tool will make it work again. The only solution in this case is to buy a new drive. (See also:Recover deleted files for free: recover lost data.)

Step 3 of 4:



If you can’t find StorageDevicePolicies, you can try creating a key by right-clicking in the white space in the Control folder and choosing New -> Key and carefully entering the name.

Now double-click on the new key (folder) and right-click once again and choose New -> DWORD. Name it WriteProtect and set its value to 0. Click OK, exit Regedit and reboot your computer.
If this method doesn’t work, skip to the next step.

Step 4 of 4:




Removing write-protection using Diskpart

With your USB drive plugged in, launch a command prompt. Do this by searching for cmd.exe in the Start menu (or Start screen in Windows 8). In Windows XP, click Start then Run, and type cmd.exe in the box.


NOTE: you may need to run Cmd.exe with administrator privileges if you see an “access is denied” message.
To do that, right-click on the shortcut and choose Run as administrator. In Windows 8, simply choose Command prompt (admin).
Now, type the following, pressing Enter after each command:
diskpart
list disk
select disk x (where x is the number of your USB flash drive – use the capacity to work out which one it is)
attributes disk clear readonly
clean
create partition primary
format fs=fat32  (you can swap fat32 for ntfs if you only need to use the drive with Windows computers)
exit