Friday, February 20, 2015

How to get Cookies reference is getting in ashx file

Here is how you can do it if you set Cookies in different pages. Below code will help you get Cookies in ASHX file

  public void ProcessRequest(HttpContext context)
        {
            context.Response.AddHeader("Pragma", "no-cache");
            context.Response.AddHeader("Cache-Control", "private, no-cache");

            if (context.Request.Cookies["UserID"] != null && 
                context.Request.Cookies["UserID"].Value != null 
                && context.Request.Cookies["UserID"].Value.Trim() != "")
            {
                UserID = Convert.ToInt32(context.Request.Cookies["UserID"].Value);
            }

            HandleMethod(context);
        }
Hope this helps !!

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.