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

Friday, October 24, 2014

How do you clear temporary files in an ASP.NET website project?

All you need to do is stop IIS from Services, go to c:\Windows\Microsoft.NET\Framework\v4.0.30319\ or respective Framework directory, open the Temporary ASP.NET Files and delete the folders

What happens when we delete these files? Is it safe?

Yes, it's safe to delete these, although it may force a dynamic recompilation of any .NET applications you run on the server.

For background, see the Understanding ASP.NET dynamic compilation article on MSDN.

Thursday, October 16, 2014

How To Disable Right Click Using jQuery

There are many different ways where we can disable right click on browser but using jQuery its very easy with one line of code.

Add the below code into the head section of your web page.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(document).bind("contextmenu", function (e) {
e.preventDefault();
});
});
</script>

How To Show A Message When DataList Is Empty

DataList doesn’t have EmptyDataTemplate like GridView or ListView, Here is how we can achieve use FooterTemplate in DataList

<FooterTemplate>
<asp:Label ID="lblEmpty" Text="No test types found." runat="server"
Visible='<%#bool.Parse((SearchValuesList.Items.Count == 0).ToString())%>'> </asp:Label>
</FooterTemplate>


Sunday, September 21, 2014

How To Encrypt Stored Procedure In SQL Server

There are some situations where business logics wants to hide the logic implementation, in those scenarios schema of the stored procedure can be encrypted.

Use AdventureWorks2008
go

CREATE PROCEDURE uspEncryptedPersonAddress
WITH ENCRYPTION
AS
BEGIN
SET NOCOUNT ON
SELECT * FROM Person.Address
END


If some one try to view using sp_helptext this is what they see


The text for object 'uspEncryptedPersonAddress' is encrypted.

Thursday, September 11, 2014

How To Display Current Time on Page using Javascript

Here is the JavaScript function which will get current time in Military format.

<script type="text/javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('Showtime').innerHTML=h+":"+m+":"+s;
t=setTimeout(function(){startTime()},500);
}

function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>

Sunday, August 24, 2014

How To Copy Content From a protected Webpage

Sometimes it is very annoying when you want to copy any news or article or anything that you want to save and when you right clicks on it but it shows “Right click disabled”. Here are some tips that can be useful on different browsers

For Mozilla FireFox:

Step 1: Open any website that have blocked your right click.
Step 2: Go to Tools>Options>Content
Step 3: Uncheck the box “Enable JavaScript”
Step 4: Click OK

For Internet Explorer:

Step 1: Open the site.
Step 2: Go to Tools>Internet options>Security
Step 3: Now Click on Custom Level
Step 4: Now find Scripting Section it will be around the end.
Step 5: Now disable Active Scripting.This will disable JavaScript and vbscript in your browser.
Step 6:Click on OK.

For Google Chrome:

Step 1: Open the site.
Step 2: Go to settings.
Step 3: Expand Show Advance settings, On Privacy tab.Click on Content Settings.
Step 4: Disable java script and open the website.

Tuesday, August 12, 2014

How to Parse datetime in multiple formats

Here is how we can parse different date formats get validated using one function.

In VB.NET

'''Validate method for Date format
  Private Function validateDate(ByVal strDate As String, ByVal strColumnName As String) As String
        Dim strError As String = ""
        Dim provider As CultureInfo = CultureInfo.GetCultureInfo("en-us")
        Dim formatStrings As String() = {"MM/dd/yyyy", "yyyy-MM-dd", "d"}
        Dim dateValue As DateTime
        Try
            If DateTime.TryParseExact(strDate, formatStrings, provider, DateTimeStyles.None, dateValue) Then
                strError = "Success"
            Else
                strError = "Failed"
            End If
        Catch ex As Exception

        End Try
        Return strError
    End Function

In C#

///Validate method for Date format
private string validateDate(string strDate, string strColumnName)
{
    string strError = "";
    CultureInfo provider = CultureInfo.GetCultureInfo("en-us");
    string[] formatStrings = {
        "MM/dd/yyyy",
        "yyyy-MM-dd",
        "d"
    };
    DateTime dateValue = default(DateTime);
    try {
        if (DateTime.TryParseExact(strDate, formatStrings, provider, DateTimeStyles.None, out dateValue)) {
            strError = "Success";
        } else {
            strError = "Failed";
        }

    } catch (Exception ex) {
    }
    return strError;
}

Add as many as formatters to the formatStrings array and use this funtion. Happy Coding ☺☻

Thursday, August 07, 2014

How to enable browser compatibility mode for your website

After every browser major release there will be something's which always mess up. Can’t say its always but it has happened so far :- )

So you might asked to force to the stable version of the browser to make sure your web application renders well in the browser. Here are some things we can add to existing page to make sure it works in the compatible mode by forcing the version we would like to render.

Method 1: If its at page level.

<head>
<!-- Mimic Internet Explorer 9 -->
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" >
<title>My webpage</title>
</head>



Method2: You can do the same globally in web.config by adding code like below


<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=EmulateIE9" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>


The value attribute is used to set the default render engine to render page. If you are looking for IE8 compatibility use the following code


<add name="X-UA-Compatible" value="IE=EmulateIE8" />


we can also use this tag


<add name="X-UA-Compatible" value="IE=Edge" />


IE=edge indicates that IE should always use its latest rendering engine to render the page. This should ensure the page is rendered consistently with other browsers and in a standards-compliant manner


The following is the documentation that I've used to try understand how IE decides to actually trigger the compatibility mode.

http://msdn.microsoft.com/en-us/library/ff406036%28v=VS.85%29.aspx

http://blogs.msdn.com/b/ie/archive/2009/02/16/just-the-facts-recap-of-compatibility-view.aspx

Wednesday, July 16, 2014

Thank you Google!

I didn’t know Google does this. I was just shocked to realize this to what I got to see on my birthday! Thanks Google you rock. This is the one of the most intuitive thing you have ever done to keep us happy.

 

google doogle -nagasai

Thursday, May 29, 2014

How to search a column name within all tables of a database?

Here is how we can get table name and column which you are looking for,

SELECT table_name,column_name FROM information_schema.columns
WHERE column_name like '%engine%'
-- OR ---
SELECT c.name AS ColName, t.name AS TableName
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE c.name LIKE '%engine%'



Sample OUTPUT for one of the query,


ColName    TableName
EngineType    DSS_Setup

Friday, April 18, 2014

CRICPICKS : APPS

For those who are not aware of Cricpicks Apps we are now available on both App Store and Google Play.

Please note that you can download CRICPICKS mobile applications from Google Play and we are coming soon on Mac App Store for iTunes! 

Have fun playing CRICPICKS and good luck winning prizes!

How do I clear the Facebook Share's Cache?

Sometimes you have a new description, title or thumbnail image in your website. But when you share the website URL on Facebook, it may still using the old description/ title/ image that no longer exists.

In order to clearing the Facebook sharer cache, there are few different ways like using tinyurls or modifying the URL by adding query strings. Since Facebook considers each one as different URL this might be quick way to do it.

The best and preferred way is to use Facebook Debugger tool which is formerly known as URL Linter to clear fb cache of your website. Go to below link and Type your website's or article's URL there and click debug button..

http://developers.facebook.com/tools/debug

After doing this, re-share your website's link on Facebook. You can find that Facebook sharer displaying your latest content.

Hope this helps!!

Monday, April 14, 2014

CRICPICKS–IPL PICK’EM GAMES

We friends have developed IPL Pick’em Game site for Cricket. You might have seen Fantasy games and other Pick’em games in football and others sports. We have brought Pick’em contest to CRICKET!. Yes that’s REAL. We took IPL to next level.

CRICPICKS is a great site to play PICKS competition and win may prizes. It is a very simple game, all you need is a valid email address and pick who will win a match of the tournaments. The site provide help to do your pick. You too can join the CRIPICKS competition for FREE to play and WIN many prizes. For more details go to CRICPICKS

Features:

  1. Play against all registered users
  2. Create your own groups and play with the same group at the same time. You can create your own group and work and apartments etc. and have fun by leading your groups.
  3. Groups created by you can be managed by multiple users by making them as Moderators of your group.
  4. You can set reminders of your favorite teams matches. So need to worry that you will miss action. We take care of this for you by sending match reminders.
  5. And more over its absolutely free and you can get weekly prizes up to $ 100 or Rs 6000.00/- in cash and also you will be eligible of for Grand prize of winning a tablet this season.

Please note that you can download CRICPICKS mobile applications from Google Play and we are coming soon on Mac App Store for iTunes! 

Have fun playing CRICPICKS and good luck winning prizes!

Friday, March 28, 2014

Remove the AnchorTag Border

I have a AJAX Tab container and in that on selection its giving me a border on the Header Text of the Tab. To remove this using CSS, here is how we can do it

.ajax__tab_inner a.ajax__tab_tab{width:100%;border:0 !important;outline: none; }


a:focus { 
        outline: none; 
    }


This is what will fix the issue. Hope this helps!

Thursday, March 27, 2014

How to change or add script tag source from C#?

Here is how we can add script to page header from code behind in c#. The reason why I am doing this is I have these JavaScript files included in master page. And when I try to give path of these files I am getting issues with absolute page when I got to other pages since I have these in master page.

and one more reason why I did is I don’t want to change this every time if deploy to different environment from QA, Stage and Production.

This is how we can do it in your master page.

string js1 = HttpContext.Current.Request.ApplicationPath + "/Scripts/jquery.cycle2.js";
string js2 = HttpContext.Current.Request.ApplicationPath + "/Scripts/jquery.countdown.js";

Literal js1script = new Literal();
js1script.Text = string.Format(
@"<script src=""{0}"" type=""text/javascript""></script>", js1);
Page.Header.Controls.Add(js1script);

Literal js2script = new Literal();
js2script.Text = string.Format(
@"<script src=""{0}"" type=""text/javascript""></script>", js2);
Page.Header.Controls.Add(js2script);

Hope this is useful!!

Tuesday, March 11, 2014

How to insert a line break in a SQL Server VARCHAR/NVARCHAR string

There are some scenarios where we need to put line breaks in the string we write back from procedure or any dynamic SQL we use.

Here is how we can do this by adding CHAR(13) or CHAR(10) in between the string we write back. This will insert carriage return(code 13) or newline feed(code 10) in the text leading to the text format as you are trying to get.

DECLARE @ReturnMsg NVARCHAR(100)
SET @ReturnMsg = 'Missing state information.' + CHAR(13) + 'This is Address line 1.'
SELECT @ReturnMsg

Monday, March 10, 2014

How to access a div or HTML controls is inside a gridview?

Here is an example of how to access a div inside the TemplateColumn of a Grid:

aspx:

<asp:TemplateField HeaderText="Pick" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center">
<ItemStyle Width="60px" />
<ItemTemplate>
<div id="divpickstatus" runat="server">
</div>
</ItemTemplate>
</asp:TemplateField>



codebehind



protected void gridview_schedule_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
HtmlGenericControl divpickstatus = (HtmlGenericControl)e.Row.FindControl("divpickstatus");
}
}
Hope this helps.

Saturday, March 08, 2014

Create Windows admin user from command line

Here is how we can create windows user from command prompt.
c:\net user /add [username] [password]
The above will creates the user account.

To add the user account to administrators group. Need to do like this below
c:\net localgroup administrators [username] /add

Hope this helps!

Guide to Resetting a Windows 7 Password

Every one has tendency to forget passwords. I am one of them. Here is the nice tutorial to reset windows 7 password which helped me. Its very helpful and nice tutorial. Author has done very good job for compiling this.

Hope this helps to you as well.

Wednesday, February 12, 2014

Delete a table data using JOINS in SQL Server

Here is how we can delete using JOINS. I have used inner join here.

DELETE
Table1
FROM
Table1 INNER JOIN Table2
ON Table1.Field2 = Table2.Field2
WHERE -- YOUR WHERE CONDITIONS
Table2.Field3 IS NOT NULL


Hope this helps

Update a table using JOINS in SQL Server

Here is how we can update a table using JOINS in SQL SERVER.

UPDATE
Table1
SET
Table1.Field1 = Table2.Field1
FROM
Table1
INNER JOIN Table2 ON Table1.Field2 = Table2.Field2
WHERE -- YOUR WHERE CONDITIONS
Table2.Field3 IS NOT NULL


Hope this helps

Friday, January 10, 2014

How to hide all Validators from JavaScript in .NET?

Here is how you can hide all validator messages from below JavaScript.  

function HideValidators() {
if (window.Page_Validators)
for (var vI = 0; vI < Page_Validators.length; vI++) {
var vValidator = Page_Validators[vI];
vValidator.isvalid = true;
ValidatorUpdateDisplay(vValidator);
}
}

Tuesday, January 07, 2014

How to hide Validation controls from JavaScript in .NET?

Here is how you can hide validation summary using the below JavaScript.  Call this in your aspx page. This should do trick for you.

// Hiding all validation contorls  
for (i = 0; i < Page_Validators.length; i++) {
ValidatorEnable(Page_Validators[i], false)
}


It works in IE and Mozilla. Hope this helps

How to: Set default database in SQL Server

Happy New Year to you all, Its been while I have stopped blogging. To get started back to blogging I have started with this small tip which saves your time. After all time is what we don’t have these days.

In SSMS whenever we connect to any database server by default the master database. Which forces us in changing the database to the one we want work using the USE statement or by using mouse and changing the selected db from the drop-down list. So this we will be doing this all-day and wasting time by doing this multiple times.

As a developer by default we mostly connect to single database at times specific to our project. So SQL Server Management Studio (SSMS) provides a way to change this. And next time onwards this new selected database will selected by default instead of the MASTER DB.

Here are the Steps:

  1. Open SQL Server Management Studio
  2. Select the instance you want to configure and connect to it by using your preferred authentication
  3. Go to object Explorer -> Security –> Logins
  4. Right click on the login and select properties
  5. And in the properties window change the default database to the one you want to select and click OK.

defaultdb

Alternatively, we can change this by below simple statement as well:

-- @loginame --login name is the you use for SQL authentication
-- @defdb -- name of the default database
Exec sp_defaultdb @loginame='sa', @defdb='Test'