Friday, November 7, 2008

Now Test AJAX, Javascript using WEBAii + NunitASP

Few Days before i had requirement to write automation testing tool for a Web application which was having web pages with Ajax functionality but as you all know we can't test client side script using NUnitAsp then i found a very nice tool that is very cool and free having many more features than NunitASP. I bet you, you guys will like this tool very much
You can download and learn it from
http://www.artoftest.com/webaiifxproduct.aspx

Thursday, July 10, 2008

AjaxToolKit 1.0.20229.0 ModalPopUp Extender IE 6.0 UI issue

Hi All,
In my previous post we fixed issue of AjaxToolKit ModalPopUpExtender in IE 7.0.
Now if you are using AjaxToolKit version 1.0.20229 while using ModalPopUp Extender in IE 6.0 it will add huge vertical and horizontal space in IE 6.o User can scroll vertical and horozontal to indefinite.

The solution for this is download the sorce code(DownLoad Source code) and Modify the below file

File Name: ModalPopupBehavior.js
Location : AjaxControlToolkit\ModalPopupExtender\ModalPopupBehavior.js
Function: _layoutBackgroundElement



Please comment out this lines of code only in this function

// Background element needs to cover the visible client area completely hence its
// top and left coordinates need to be 0, and if relatively positioned its getlocation
// value needs to be 0.
// if(this._isIE6) {
// var backgroundLocation = $common.getLocation(this._backgroundElement);
// var backgroundXCoord = backgroundLocation.x;
// if (backgroundXCoord != 0) {
// // offset it by that amount. This is assuming only one level of nesting. If
// // multiple parents with absolute/relative positioning are setup this may not
// // cover the whole background.
// this._backgroundElement.style.left = (-backgroundXCoord) + 'px';
// }
//
// var backgroundYCoord = backgroundLocation.y;
// if (backgroundYCoord != 0) {
// // offset it by that amount. This is assuming only one level of nesting. If
// // multiple parents with absolute/relative positioning are setup this may not
// // cover the whole background.
// this._backgroundElement.style.top = (-backgroundYCoord) + 'px';
// }


After commenting out these lines Rebuild the whole solution and use the newly created dll in your application

Now see the spacing issue should get resolved

Thanks & regards
Sandeep

AjaxToolKit 1.0.20229.0 ModalPopUp Extender IE 7.0 UI issues

Hi All,
AjaxToolKit version 1.0.20229.0 ModalPopUpExtender has some issues like it won't work in IE 7.0 . When Modal PopUP is shown it disturbed the whole UI of Page. I got fix for it for which just download the AjaxTool kit source code DownLoad Source Code and modify with following files with given code.

1. IE 7.0 UI Issue. (i.e UI was getting totally disturbed after populating the Modal pup )
File Name: Common.js
Location: AjaxControlToolkit\Common\Common.js
Function: getClientBounds



Replace the switch statement with the following one:

switch(Sys.Browser.agent) {case Sys.Browser.InternetExplorer:if (document.documentElement && document.documentElement.clientWidth)clientWidth = document.documentElement.clientWidth;else if (document.body)clientWidth = document.body.clientWidth;//clientWidth = document.documentElement.clientWidth;if (document.documentElement && document.documentElement.clientHeight)clientHeight = document.documentElement.clientHeight;else if (document.body)clientHeight = document.body.clientHeight;//clientHeight = document.documentElement.clientHeight;break;case Sys.Browser.Safari:clientWidth = window.innerWidth;clientHeight = window.innerHeight;break;case Sys.Browser.Opera:clientWidth = Math.min(window.innerWidth, document.body.clientWidth);clientHeight = Math.min(window.innerHeight, document.body.clientHeight);break;default: // Sys.Browser.Firefox, etc.clientWidth = Math.min(window.innerWidth, document.documentElement.clientWidth);clientHeight = Math.min(window.innerHeight, document.documentElement.clientHeight);break;}


2. IE 7.0 issue Modal Pop up Position was not absolute
File Name: ModalPopupBehavior.js
Location: AjaxControlToolkit\ModalPopupExtender\ModalPopupBehavior.js
Function: initialize
(Line number might be 113 )
a. Check for this statement this._backgroundElement.style.position = 'fixed';change it to thisthis._backgroundElement.style.position = 'absolute';//'fixed';
b. A few lines below that is another change that has to be made from: (Line number 125 )this._foregroundElement.style.position = 'fixed';
to:
this._foregroundElement.style.position = 'absolute';//'fixed';


Now build the AJAXtoolKit solution use its newly created dll instead of old one.
Now you will see the IE 7.0 UI issue got resolved.


But there is still one more Issue that is with IE 6.0 Flickering of background that I have resolved ine my next post please see my Next post


Tuesday, September 11, 2007

Remember me in javascript

Hi All,
Just i have developed one Logged in page which will store UserName and password in cookie. Many times (similar to Gmail) user have given the option of Remember me on this computer and user selects that check box and click logged in. Now when second times user hit the login page . After writing it UserName we are checking that user name in cookies. If present the password will get automatically added to password text box see the javascript code.

function readCookie(cookies)
{
var txtuname= document.getElementById('TxtBxUserName');
var txtpass= document.getElementById('TxtBxPassword');
//alert(document.cookie);
if (document.cookie.length>0)
{
// check the index of the username that is entered by user in Username text box
var c_start=document.cookie.indexOf(txtuname.value);
if (c_start!=-1)
{
c_start=c_start + txtuname.value.length +1 ;
var c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1)
{
c_end=document.cookie.length;
}
var value= unescape(document.cookie.substring(c_start,c_end));
var arr = new Array(2);
arr= value.split('',2)
// alert(arr[0]+arr[1]) ;
txtuname.value=arr[0];
txtpass.value=arr[1];
}
else
{
txtpass.value="";
}
}
}

Now the At the server side check user authentications and authenticated user can store it's password


protected void LoggedIn_Click1(object sender, EventArgs e)
{ // do authentication
if(AuthenitcateUser())
// if the remember me check box ic checked
if (ChkBxRememberMe.Checked)
{ // create the cookie with userName as name
HttpCookie cookie = new HttpCookie(TxtBxUserName.Text);
// add cookie first to response
Response.Cookies.Add(cookie);
// add the user name and password as value
cookie.Values.Add("",TxtBxUserName.Text + "" + TxtBxPassword.Text + ";");
// this step is important remember it
Response.Cookies[TxtBxUserName.Text].Expires = DateTime.Now.AddDays(15);
}
}
}


Now call the javascript onfocus event of password textbox in page load



protected void Page_Load(object sender, EventArgs e)
{
TxtBxPassword.Attributes.Add("OnFocus", "javascript:readCookie('"+this.Request.Cookies+"');");
}