Thursday, August 18, 2011
XSD 2d buug
Unable to generate a temporary class (result=1).
error CS0030: Cannot convert type 'Data[]' to 'Data'
error CS0029: Cannot implicitly convert type 'Data' to 'Data[]'
read on, otherwise you might be facing something different.
The problem is the xsd.exe tool has a bug when it comes to mapping to a multidimensional array. In most cases you can easily fix it by hand.
In my case, I ran a search on the Data type name in the generated file, and I found this:
[System.Xml.Serialization.XmlArrayItemAttribute("Data", typeof(Data), IsNullable=false)]
public Data[][] Row
As it can be seen, the type of the elements of a Data[][] array is not Data, but Data[]. The only change required was:
[System.Xml.Serialization.XmlArrayItemAttribute("Data", typeof(Data[]), IsNullable=false)]
public Data[][] Row
Happy coding, and hopefully we'll be spared of this kind of framework bugs in the future.
Monday, January 24, 2011
Cross Browser Script
// Check Empty Fields..
function CheckEmpty(val)
{
if(val.replace(/^\s*|\s*$/g,‘ ’)==‘ ’)
{
return false;
}
return true;
}
// new function to disable spacebar on cross browserfunction
DisableSpacebar(evt)
{
evt = (evt) ? evt : (window.event) ? event : null;
if (evt)
{
var charCode = (evt.charCode) ? evt.charCode :
((evt.keyCode) ? evt.keyCode :
((evt.which) ? evt.which : 0));
if(charCode==32)
{
return false;
}
}
}
///function to check number on cross browsers
function NumberOnly(evt)
{
evt = (evt) ? evt : (window.event) ? event : null;
if (evt)
{
var charCode = (evt.charCode) ? evt.charCode :((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));
if(charCode>47 && charCode<58)
{return true;
}
else if(charCode==8||charCode==9||charCode==17)
{
return true;
}
else if(charCode>32 && charCode<41|| charcode==46)
{
return true;
}
else if(charCode==16||charCode==18 || charCode==19||charCode==27)
{
return true;
}
else {
return false;
}
}
}