Tuesday, January 27, 2015

How to access ViewState of one page in another page in Asp.Net?

You can't access ViewState of one page from another page directly. If you want to access a particular ViewState value then you can pass the value in Context collection and then access the value in other page.

In Page 1:

Context.Items.Add("employee" ,ViewState["employee"].ToString());


In Page 2:


string employeeName = Context.Items["employee"].ToString();

Hope this helps!

How to: Disable Button after Click while maintaining CausesValidation and an OnClick-Method

Here is how you can do it by adding these two lines in your code behind to prevent multiple clicks on a button.

string strProcessScript = "if (!Page_ClientValidate()){ return false; } else{ this.value='Processing...';this.disabled=true; }";
CheckOutButton.Attributes.Add("onclick", strProcessScript + ClientScript.GetPostBackEventReference(CheckOutButton, "").ToString());

If you have ASP.NET Validation controls in your page, then you might need to do this by adding specific validation group to Page_ClientValidate method.

string strProcessScript = "if (!Page_ClientValidate('PaymentValidationGroup')){ return false; } else{ this.value='Processing...';this.disabled=true; }";
CheckOutButton.Attributes.Add("onclick", strProcessScript + ClientScript.GetPostBackEventReference(CheckOutButton, "").ToString());
 
Only thing you need to change in ASPX is to add following attribute in ASP Button code UseSubmitBehavior="false"
 
<asp:Button runat="server" ID="PaymentCheckOutButton" ValidationGroup="PaymentValidationGroup"                                          
Text="Proceed to Checkout" UseSubmitBehavior="false" class="btn btn-primary btn-cons pull-right" OnClick="PaymentCheckOutButton_Click" />
 
Hope this helps!!

Saturday, January 03, 2015

Happy New Year 2015

I wish you and your family a happy, healthy New Year. I hope that 2015 is a year of dreams fulfilled and happiness achieved. I hope all of us are able to meet the inevitable challenges and setbacks with heart and fortitude. May 2015 bring you all great happiness, health, and prosperity.

happy-new-year-wallpaper

Thank you so much for being with me & thank you so much for your kindness & care.

Tuesday, November 25, 2014

Fixed: Android USB issue for Nexus 5 which won't connect to your PC?

It seems like many of you are having problems connecting your Nexus 5 to Windows 8 and Windows 8.1. The smartphone appears in the device manager of Windows 8.1, but it is impossible to perform any action with it. No files can be transferred from the Nexus 5 on the PC, and the smartphone is invisible in the file explorer. Here is a confirmed solution, which should resolve connection issues where your PC won't read your Nexus 5.

Since the last set of Microsoft updates, I cannot connect my nexus 5 or nexus 7 (android 4.4.4) to my windows 8.1 64bit desktop. Here is the solution

Its really a driver (or an incorrect drive allocated issue, due to be knocked out by updates) issue.
1. In Nexus 5 or 7, make sure USB debugging mode is enabled, and go into storage and hit menu USB connection and ensure USB mode is set to MTP. First make sure that the MTP is enabled on the Nexus 5: Settings > Storage > Menu > USB connection to the computer
2. Connect tablet to PC.
3. In windows device manager find ADB Driver (May be Acer) then drill down. Right click and select "update driver software".
4. Select "Browse my computer for driver software".
5. Select "Let me pick from a list of device drivers on my computer."
6. With "show compatible hardware" checkbox ticked, two drivers should be shown.
(a) Android ADB Interface. and (b) MTP User Device or Composite USB device.

image
7. Select (b) above and click Next.
8. Device should now appear in Portal devices section with your device name.

Wednesday, November 05, 2014

How to delete a file or folder with a path too long?

I have come across a situation where I am unable to delete a folder? Interesting right. I tired different ways to delete like how we does in Windows like every time we do. But no luck. After I did some research I found a way to delete file or folder which is too long to delete.

Here is the error message you will get when you try to delete these files or folders “Destination Path Too Long:  The file name(s) would be too long for the destination folder.  You can shorten the file name and try again, or try a location that has a shorter path.

Usually windows cannot delete file path greater than 255 characters.

So here is the simple way to delete these folders by doing Map Drive to that location. Here is how we can do using command prompt.

  1. Start a command prompt (no admin privileges needed)
  2. Use cd to navigate to the folder you want to go (you can use tab to autocomplete names)
  3. Type subst Z:  to create the drive letter association. (instead of the . you can also type the entire path)
    C:\>subst Z:  d:\Java.Works\adt-bundle-windows-x86_64-20140702
  4. Now in explorer you have a new letter in your computer. Go to it and do whatever you need to do to like by navigate to the files that have long names. You should now be able to rename/delete/etc them. The reason this works is because the path itself is no longer containing >255 chars
  5. Go back to your cmd window and type subst /d Z: to remove the drive like this C:\>subst /d Z:

This worked for me. Hope it works for you as well. Good luck