Thursday, June 30, 2005

Free Book - Introducing Visual Basic 2005 for Developers


Get a focused, first look at the features and capabilities in Microsoft Visual Basic 2005, Visual Studio 2005, and .NET Framework 2.0.

If you currently work with Visual Basic 6, these authors fully understand the adoption and code migration issues you’ll encounter.

They’ll step you through a quick primer on .NET Framework programming, offering guidance for a productive transition.

If you already work with .NET, you’ll jump directly into what’s new, learning how to extend your existing skills.

From the innovations in rapid application development, debugging, and deployment, to new data access, desktop, and Web programming capabilities, you get the prerelease insights and code walkthroughs you need to get productive right away.



Check out this free eBook here

Monday, June 27, 2005

Problem with slow debugging

My friend recently had a problem with slow debugging. It took a few minutes before debugger went to the next statement.

Clearing all breakpoints helped. He had a lot of them. So if you have the same problem, check how many breakpoints you have defined.

Saturday, June 25, 2005

Two things that “bugs” me in VS .NET 2003 + how to avoid them

There are two main things that drives me crazy:
  1. Erasing event handlers.
    Sometimes Visual Studio .NET 2003 erases event handlers.
    What I see is that it occurs after working in html mode. What you can do is attach events manually after the InitializeComponent() call, instead of using the properties editor.

  2. "Close all documents" closes VS. NET IDE
    When you click “Window/Close All Documents” VS.NET sometimes terminates (very, very fast. I have never seen VS closing so fast).
    To avoid this try “Window/Windows” then select all windows and click “Close Window(s)”.

Sunday, June 19, 2005

Group validators in ASP.NET on client side – finally!

Finally that time came. Time to face with the lack of group validators problem. I had two choices: loop up a solution for that in the Internet or fix it on my own.
I decided that first I will try to find something on the Internet. Maximum time for that is 20 minutes, after that I’m fixing it on my own.

After about 5 minutes I have found a fix for that.

I found it on ASP.NET forums. It’s a post by jgallant (Joe Gallant I presume)
http://forums.asp.net/296304/ShowPost.aspx Check out Joe's post on how to implement it.

I found that the posted WebUIValidation.js file didn’t worked for me, so I fixed it.
Plus I added a little patch that when a button doesn’t have assigned validator it validates all (before JavaScript error showed up)

You can view and download my version of this file WebUIValidation.js.txt (look out for the txt extension).

Big thanks Joe for posting this and for a detailed explanation.

Blogger does not let you attach files to posts so here is the content of the "WebUIValidation.js" file


var Page_ValidationVer = "125";

var Page_IsValid = true;

var Page_BlockSubmit = false;

function ValidatorUpdateDisplay(val) {

if (typeof(val.display) == "string") {

if (val.display == "None") {

return;

}

if (val.display == "Dynamic") {

val.style.display = val.isvalid ? "none" : "inline";

return;

}

}

val.style.visibility = val.isvalid ? "hidden" : "visible";

}

function ValidatorUpdateIsValid() {

var i;

for (i = 0; i < page_isvalid =" false;" page_isvalid =" true;" ctrl =" document.all[controlID];" isvalid =" true;" enabled =" false;" i =" 0;" inner =" control;" i =" 0;" validators =" new" type ="="" ev =" control.onclick;" ev =" control.onchange;" ev =" ev.toString();" ev =" ev.substring(ev.indexOf(" ev = "" func =" new" type ="="" onclick =" func;" onchange =" func;" control =" document.all[id];" j="0;" inner =" control[j];" status ="="" status ="="" i =" 0;">< page_validators =" eval(Page_Validators);" i =" 0;" isvalid =" true;" i =" 0;" page_blocksubmit =" !Page_IsValid;" result =" !Page_BlockSubmit;" page_blocksubmit =" false;" returnvalue =" result;" enabled =" (enable" vals =" event.srcElement.Validators;" i =" 0;" isvalid =" true;" isvalid =" val.evaluationfunction(val);" i =" 0;" val =" Page_Validators;" evaluationfunction = " + val.evaluationfunction + " isvalid ="="" isvalid =" false;" page_isvalid =" false;" isvalid =" true;" isvalid =" true;" enabled =" (val.enabled" page_validationactive =" true;" datatype ="="" exp =" /^\s*[-\+]?\d+\s*$/;" num =" parseInt(op," datatype ="="" exp =" new" m =" op.match(exp);" m ="="" cleaninput =" m[1]">0 ? m[2] : "0") + "." + m[4];

num = parseFloat(cleanInput);

return (isNaN(num) ? null : num);

}

else if (dataType == "Currency") {

exp = new RegExp("^\\s*([-\\+])?(((\\d+)\\" + val.groupchar + ")*)(\\d+)"

+ ((val.digits > 0) ? "(\\" + val.decimalchar + "(\\d{1," + val.digits + "}))?" : "")

+ "\\s*$");

m = op.match(exp);

if (m == null)

return null;

var intermed = m[2] + m[5] ;

cleanInput = m[1] + intermed.replace(new RegExp("(\\" + val.groupchar + ")", "g"), "") + ((val.digits > 0) ? "." + m[7] : 0);

num = parseFloat(cleanInput);

return (isNaN(num) ? null : num);

}

else if (dataType == "Date") {

var yearFirstExp = new RegExp("^\\s*((\\d{4})|(\\d{2}))([-./])(\\d{1,2})\\4(\\d{1,2})\\s*$");

m = op.match(yearFirstExp);

var day, month, year;

if (m != null && (m[2].length == 4 || val.dateorder == "ymd")) {

day = m[6];

month = m[5];

year = (m[2].length == 4) ? m[2] : GetFullYear(parseInt(m[3], 10))

}

else {

if (val.dateorder == "ymd"){

return null;

}

var yearLastExp = new RegExp("^\\s*(\\d{1,2})([-./])(\\d{1,2})\\2((\\d{4})|(\\d{2}))\\s*$");

m = op.match(yearLastExp);

if (m == null) {

return null;

}

if (val.dateorder == "mdy") {

day = m[3];

month = m[1];

}

else {

day = m[1];

month = m[3];


}

year = (m[5].length == 4) ? m[5] : GetFullYear(parseInt(m[6], 10))

}

month -= 1;

var date = new Date(year, month, day);

return (typeof(date) == "object" && year == date.getFullYear() && month == date.getMonth() && day == date.getDate()) ? date.valueOf() : null;

}

else {

return op.toString();

}

}

function ValidatorCompare(operand1, operand2, operator, val) {

var dataType = val.type;

var op1, op2;

if ((op1 = ValidatorConvert(operand1, dataType, val)) == null)

return false;

if (operator == "DataTypeCheck")

return true;

if ((op2 = ValidatorConvert(operand2, dataType, val)) == null)

return true;

switch (operator) {

case "NotEqual":

return (op1 != op2);

case "GreaterThan":

return (op1 > op2);

case "GreaterThanEqual":

return (op1 >= op2);

case "LessThan":

return (op1 < op1 ="="" value =" ValidatorGetValue(val.controltovalidate);" length ="="" compareto = "" null ="="" compareto =" val.valuetocompare;" compareto =" ValidatorGetValue(val.controltocompare);" value = "" value =" ValidatorGetValue(val.controltovalidate);" length ="="" args =" {" value =" ValidatorGetValue(val.controltovalidate);" length ="="" rx =" new" matches =" rx.exec(value);" value ="="" m =" s.match(/^\s*(\S+(\s+\S+)*)\s*$/);" m ="="" value =" ValidatorGetValue(val.controltovalidate);" length ="="" sums =" 0;" summary =" Page_ValidationSummaries[sums];" display = "none" display = "" displaymode = "BulletList" headersep =" ">
";

first = "";

pre = "";

post = "
";

final = "";

break;

case "BulletList":

default:

headerSep = "";

first = "
    ";

    pre = "
  • ";

    post = "
  • ";

    final = "
";

break;

case "SingleParagraph":

headerSep = " ";

first = "";

pre = "";

post = " ";

final = "
";

break;

}

s = "";

if (typeof(summary.headertext) == "string") {

s += summary.headertext + headerSep;

}

s += first;

for (i=0; i

";

}

for (i=0; i

";

break;

case "BulletList":

default:

s += " - " + Page_Validators.errormessage + "
";

break;

case "SingleParagraph":

s += Page_Validators.errormessage + " ";

break;

}

}

}

span = document.createElement("SPAN");

span.innerHTML = s;

s = span.innerText;

alert(s);

}

}

}

}

function InArray(array, value, attribute)

{

if( attribute != null )

attribute += ".";



for(var i = 0; i <>

{

if( eval('array.' + attribute + 'toString().toLowerCase()') == value.toString().toLowerCase() )

return i;

}

return -1;

}