4 Simple Tools to Find Broken Links in your Site

Broken links or a 404 error is a webmaster’s nightmare. The task of detecting linkrots becomes even more challenging when the website is huge. Here are 4 tools that can make this task easier for you, by detecting Broken Links in your Site.

W3C Link Checker – Checks and detects issues in links, anchors and referenced objects in Web pages or full Web sites. Enter the url or webpage address you want to check and click on the ‘Check’ Button. The tool takes sometime to analyze and detect the broken links. There are various other options given in the screenshot below that can be selected while checking links.

imagec

Xenu’s Link Slueth – Is a very popular desktop program that checks your websites for broken hyperlinks, images, frames, plug-ins, backgrounds, local image maps, style sheets, scripts and java applets.

image

Link Checker FireFox AddOn - Check the validity of links on any webpage. Once you have installed this Addon in FireFox, choose ‘Check Page Links’ in the ‘Tools’ menu or right-click on any webpage using FireFox, to invoke this tool.

image

Dead-Link-Checker – A simple web tool that requires JavaScript enabled to detect broken links

image

Other Link Checkers - http://linkchecker.sourceforge.net/other.html

Detect Copy, Paste and Cut operations on a TextBox using jQuery

To detect Copy, Paste and Cut operations two years ago, I remember using the addEventListener and capturing the keyDown event. Then capture the KeyCode and ctrlKey to detect a copy or paste in JavaScript. Cumbersome!

Here’s how detecting copy, paste and cut operations is a cakewalk in jQuery

Detect Copy, Paste and Cut Operation in a HTML TextBox

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>Copying and Pasting in a TextBox</title>

<
script src="Scripts/jquery-1.3.2.js" type="text/javascript"></script>

<
script type="text/javascript">
$(document).ready(function() {
$("#Text1").bind('copy', function(e) {
alert('copying text!');
});
$("#Text1").bind('paste', function(e) {
alert('pasting text!');
});
$("#Text1").bind('cut', function(e) {
alert('cut text!');
});
});
</script>

</
head>
<
body>
<
input id="Text1" type="text" value="Copy Me" />
</
body>
</
html>


Update: Karl Swedberg suggested a simpler way of doing the above.

$("#Text1").bind('cut copy paste', function(e) {
alert(e.type + ' text!');
});

Detect Copy, Paste and Cut Operation in an ASP.NET TextBox

<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="jQuery2.aspx.cs" Inherits="jQuery2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<
html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
<
title>Handling Copy and Paste functions in TextBox</title>

<
script src="Scripts/jquery-1.3.2.js" type="text/javascript"></script>

<
script type="text/javascript">
$(document).ready(function() {
$("#TextBox1").bind('copy', function(e) {
alert('copying text!');
});
$("#TextBox1").bind('paste', function(e) {
alert('pasting text!');
});
$("#TextBox1").bind('cut', function(e) {
alert('cut text!');
});
});
</script>
</
head>
<
body>
<
form id="form1" runat="server">
<
div>
<
asp:TextBox ID="TextBox1" runat="server">Copy Me</asp:TextBox>
</
div>
</
form>

</
body>
</
html>


Cool..ain’t it! Just a few lines of code and you can now capture the copy, paste and cut actions on a TextBox, TextArea or any other controls that can respond to these events.

Multiple Background Images for an Element in CSS

Recently, I observed an interesting issue at one of my client’s webpage. They wanted to add multiple background images to an element. Although as per this document, doing this in CSS is possible

div {
background-image: url(images/emo.jpg) url(images/icon068.gif);
}

however not all browsers support this feature.

To get around this issue, here’s what I proposed which also works cross-browser. The trick is to place a similar element inside the parent element, in our case placing a DIV inside a DIV.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html xmlns="http://www.w3.org/1999/xhtml">

<
head>
<
meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<
title>Multiple Background Images</title>
<
style type="text/css">

#outerDiv
{
height:100px;
width:100px;
background-image: url(images/emo.jpg);
background-repeat: repeat-x;
}
#innerDiv
{
height:80px;
width:100px;
background-image: url(images/icon068.gif);
background-repeat: repeat-x;
}

</style>
</
head>

<
body>
<
div id="outerDiv">
<
div id="innerDiv">

</
div>
</
div>
</
body>

</
html>



The output is as shown below with one image placed over the other. To overlap the parent image, change the width from 100px to 80px:

image

Import Excel Data Into an ASP.NET GridView using Microsoft.Office.Interop.Excel

In my previous article, we saw how to import Excel Data into an ASP.NET GridView using OLEDB. In this next article, we will see how to import Excel Data Into an ASP.NET GridView using Microsoft.Office.Interop.Excel. This untested code was written by Vince Xu -MSFT and I thought of sharing it with you.

C#

using Microsoft.Office.Interop.Excel;
using System.Text;
using System.Reflection;

public partial class ImportDD : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DataSet ds = GetExcel("c:\\aa.xls");
GridView1.DataSource = ds;
GridView1.DataBind();
}

public DataSet GetExcel(string fileName)
{
Application oXL;
Workbook oWB;
Worksheet oSheet;
Range oRng;
try
{
// creat a Application object
oXL = new ApplicationClass();
// get WorkBook object
oWB = oXL.Workbooks.Open(fileName, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value);

// get WorkSheet object
oSheet = (Microsoft.Office.Interop.Excel.Worksheet)oWB.Sheets[1];
System.Data.DataTable dt = new System.Data.DataTable("dtExcel");
DataSet ds = new DataSet();
ds.Tables.Add(dt);
DataRow dr;

StringBuilder sb = new StringBuilder();
int jValue = oSheet.UsedRange.Cells.Columns.Count;
int iValue = oSheet.UsedRange.Cells.Rows.Count;
// get data columns
for (int j = 1; j <= jValue; j++)
{
dt.Columns.Add("column" + j, System.Type.GetType("System.String"));
}

// get data in cell
for (int i = 1; i <= iValue; i++)
{
dr = ds.Tables["dtExcel"].NewRow();
for (int j = 1; j <= jValue; j++)
{
oRng = (Microsoft.Office.Interop.Excel.Range)oSheet.Cells[i, j];
string strValue = oRng.Text.ToString();
dr["column" + j] = strValue;
}
ds.Tables["dtExcel"].Rows.Add(dr);
}
return ds;
}
catch (Exception ex)
{
return null;
}
finally
{
Dispose();
}
}

}

VB.NET

Imports Microsoft.Office.Interop.Excel
Imports System.Text
Imports System.Reflection

Partial Public Class ImportDD
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim ds As DataSet = GetExcel("c:\aa.xls")
GridView1.DataSource = ds
GridView1.DataBind()
End Sub

Public Function
GetExcel(ByVal fileName As String) As DataSet
Dim oXL As Application
Dim oWB As Workbook
Dim oSheet As Worksheet
Dim oRng As Range
Try
' creat a Application object
oXL = New ApplicationClass()
' get WorkBook object
oWB = oXL.Workbooks.Open(fileName, Missing.Value, Missing.Value,_
Missing.Value, Missing.Value,Missing.Value, Missing.Value, Missing.Value, _
Missing.Value, Missing.Value,Missing.Value, Missing.Value, Missing.Value, _
Missing.Value, Missing.Value)

' get WorkSheet object
oSheet = CType(oWB.Sheets(1), _
Microsoft.Office.Interop.Excel.Worksheet)
Dim dt As New System.Data.DataTable("dtExcel")
Dim ds As New DataSet()
ds.Tables.Add(dt)
Dim dr As DataRow

Dim sb As New StringBuilder()
Dim jValue As Integer = oSheet.UsedRange.Cells.Columns.Count
Dim iValue As Integer = oSheet.UsedRange.Cells.Rows.Count
' get data columns
For j As Integer = 1 To jValue
dt.Columns.Add("column" & j, _
System.Type.GetType("System.String"))
Next j

' get data in cell
For i As Integer = 1 To iValue
dr = ds.Tables("dtExcel").NewRow()
For j As Integer = 1 To jValue
oRng = CType(oSheet.Cells(i, j), _
Microsoft.Office.Interop.Excel.Range)
Dim strValue As String = oRng.Text.ToString()
dr("column" & j) = strValue
Next j
ds.Tables("dtExcel").Rows.Add(dr)
Next i
Return ds
Catch ex As Exception
Return Nothing
Finally
Dispose()
End Try
End Function

End Class

Import Excel Data Into An ASP.NET GridView using OLEDB

I have seen a lot of users asking how to import data from an excel sheet into an ASP.NET GridView.

I will show two ways to do so - Using OLEDB and Using Microsoft.Office.Interop.Excel

In this post, we will see how to import data using OLEDB

C#

using System.Data.OleDb;
using System.Data;

public partial class UploadD : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string cnstr = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=C:\a.xls;"
+ "Extended Properties=Excel 8.0";
OleDbConnection oledbConn = new OleDbConnection(cnstr);
string strSQL = "SELECT * FROM [Sheet$]";

OleDbCommand cmd = new OleDbCommand(strSQL, oledbConn);
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
}

VB.NET

Imports System.Data.OleDb
Imports System.Data

Partial Public Class UploadD
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim cnstr As String = "Provider=Microsoft.Jet.Oledb.4.0;" &_
"Data Source=C:\a.xls; Extended Properties=Excel 8.0"
Dim oledbConn As New OleDbConnection(cnstr)
Dim strSQL As String = "SELECT * FROM [Sheet$]"

Dim cmd As New OleDbCommand(strSQL, oledbConn)
Dim ds As New DataSet()
Dim da As New OleDbDataAdapter(cmd)
da.Fill(ds)
GridView1.DataSource = ds
GridView1.DataBind()
End Sub
End Class
In the next article, we will see how to import Excel Data Into an ASP.NET GridView using Microsoft.Office.Interop.Excel

How to Open a Page In Full Screen Mode using JavaScript

One of my team members had a requirement of opening up a page in Full Screen mode. He wanted that when a link on the page is clicked, the same page should be opened in Full Screen Mode. If you too have a similar requirement, then here’s how to do so:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<
html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>Open Page FullScreen</title>
<
script type="text/javascript">
function
FullScreenMode(){
var win = window.open("", "full", "dependent=yes, fullscreen=yes");
win.location = window.location.href;
window.opener = null;
}

</script>

</
head>
<
body>
<
input id="Button1" type="button" value="Full Screen"
onclick="FullScreenMode()"/>
</
body>
</
html>
If you want the parent window to close when the new window opens in full screen mode, just add window.close(); as the last line in the JavaScript code.

How to Refresh/Reload a Page using jQuery

I have seen this question asked in many forums, however the solution presented worked on selected browsers only. Here’s a solution I have tested that works on IE7, FireFox 3 and Chrome. Hopefully it should work on other browser versions as well!

<html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>Reload/Refresh a Page in jQuery</title>
<
script type="text/javascript"
src="http://code.jquery.com/jquery-latest.js">
</
script>

<
script type="text/javascript">
$(document).ready(function() {
$('#Button1').click(function() {
location.reload();
});
});
</script>
</
head>
<
body>
<
input id="Button1" type="button" value="button" />
</
body>
</
html>


Drop a comment if this script does not work in any browser version.

Check plenty of other jQuery Tips here

Patterns & Practices Acceptance Test Engineering Guide, Volume I – Beta2‏

Free Guide to provide guidance to technology and business stakeholders on the discipline of acceptance testing. I have copied the index 'as-is' from the guide to give you an idea about the contents of the guide.

PART I – THINKING ABOUT ACCEPTANCE explains six mental models that are useful when thinking about the acceptance process.

Chapter 1 The Acceptance Process

Chapter 2 Decision-Making Model

Chapter 3 Project Context Model

Chapter 4 System Requirements Model

Chapter 5 Risk Model

Chapter 6 Doneness Model

PARTII – PERSPECTIVES ON ACCEPTANCE describes the acceptance process from the perspectives of key stakeholders in two different kinds of organizations: the Information Technology Department in a business and the Product Development Company. Most readers involved in the acceptance process should find some commonality with at least one of the roles describes.

Chapter 7 Business Lead’s Perspective

Chapter 8 Product Manager’s Perspective

Chapter 9 Test Manager’s Perspective

Chapter 10 Development Manager’s Perspective

Chapter 11 User Experience Specialist’s Perspective

Chapter 12 Operations Manager’s Perspective

Chapter 13 Solution Architect’s Perspective

Chapter 14 Enterprise Architect’s Perspective

Chapter 15 Legal Perspective

PARTIII – ACCEPTING SOFTWARE introduces the practices that are necessary for planning the acceptance process, for performing acceptance testing and for improving the acceptance process.

Chapter 16 Planning for Acceptance

Chapter 17 Assessing Software

Chapter 18 Managing the Acceptance Process

Chapter 19 Streamlining the Acceptance Process

Download the Guide over here http://testingguidance.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=29464