[Mono-list] Script Locations of WebUIValidation.js, SmartNav.js
Gaurav Vaish
gvaish@adobe.com
Thu, 09 Oct 2003 11:03:53 +0530
This is a multi-part message in MIME format.
--Boundary_(ID_NjPBUP0BsVTvcGDepWXTxw)
Content-type: text/plain; charset=iso-8859-1
Content-transfer-encoding: 7BIT
Hi,
In the method
System.Web.UI.WebControls.BaseValidator::RegisterValidatorCommonScript()
I need information about the location of the WebUIValidator.js file kept
in system_web subdirectories when ASP.Net is registered using
aspnet_regiis.exe (-i option).
Now, there can be many versions of the ASP.Net installed and hence many
JS files - as I can see three such locations on my computer corresponding to
1.0.3755..0, 1.0.3705.288 and 1.1.4322.
I get this information from a method in class
System.Web.UI.Utils::GetScriptLocation(HttpContext) - but at the final
implementation point, I don't have the exact version information.
===> How do I get this information of the version number?
===> More precisely, the location of the JS script file.
For IIS / .Net, it's installed in
<WWWROOT>/aspnet_client/system_web/<version>/
where <WWWROOT> generally corresponds to "C:\Inetpub\wwwroot"
but for other implementations like on Apache (mod_mono) / XSP, the
installation path may differ or -- Gonazlo, are you using the same path for
the js file? The attachment contains this file... for 1.1.4322.
Cheers,
Gaurav
http://gvaish.virtualave.net
--------------------------------
[MonoTODO]
internal static string GetScriptLocation(HttpContext context)
{
IDictionary dict = context.GetConfig("system.web/webControls");
string loc = null;
if(dict != null)
{
loc = dict["clientScriptsLocation"] as string;
}
if(loc == null)
{
throw new HttpException("Missing_clientScriptsLocation");
}
if(loc.IndexOf("{0}") > 0)
{
//FIXME: Version Number of the ASP.Net should come into play.
//Like if ASP 1.0 and 1.1 both are installed, the script
// locations are in /aspnet_client/system_web/1_0_3705_0/
// and /aspnet_client/system_web/1_1_4322/
// (these entries are from my machine
// So, first I should get this Version Info from somewhere
loc = String.Format(loc, "system_web");
}
return loc;
}
--Boundary_(ID_NjPBUP0BsVTvcGDepWXTxw)
Content-type: application/x-javascript; name=WebUIValidation.js
Content-transfer-encoding: quoted-printable
Content-disposition: attachment; filename=WebUIValidation.js
var Page_ValidationVer =3D "125";
var Page_IsValid =3D true;
var Page_BlockSubmit =3D false;
function ValidatorUpdateDisplay(val) {
if (typeof(val.display) =3D=3D "string") { =20
if (val.display =3D=3D "None") {
return;
}
if (val.display =3D=3D "Dynamic") {
val.style.display =3D val.isvalid ? "none" : "inline";
return;
}
}
val.style.visibility =3D val.isvalid ? "hidden" : "visible";
}
function ValidatorUpdateIsValid() {
var i;
for (i =3D 0; i < Page_Validators.length; i++) {
if (!Page_Validators[i].isvalid) {
Page_IsValid =3D false;
return;
}
}
Page_IsValid =3D true;
}
function ValidatorHookupControlID(controlID, val) {
if (typeof(controlID) !=3D "string") {
return;
}
var ctrl =3D document.all[controlID];
if (typeof(ctrl) !=3D "undefined") {
ValidatorHookupControl(ctrl, val);
}
else {
val.isvalid =3D true;
val.enabled =3D false;
}
}
function ValidatorHookupControl(control, val) {
if (typeof(control.tagName) =3D=3D "undefined" && =
typeof(control.length) =3D=3D "number") {
var i;
for (i =3D 0; i < control.length; i++) {
var inner =3D control[i];
if (typeof(inner.value) =3D=3D "string") {
ValidatorHookupControl(inner, val);
}=20
}
return;
}
else if (control.tagName !=3D "INPUT" && control.tagName !=3D =
"TEXTAREA" && control.tagName !=3D "SELECT") {
var i;
for (i =3D 0; i < control.children.length; i++) {
ValidatorHookupControl(control.children[i], val);
}
return;
}
else {
if (typeof(control.Validators) =3D=3D "undefined") {
control.Validators =3D new Array;
var ev;
if (control.type =3D=3D "radio") {
ev =3D control.onclick;
} else {
ev =3D control.onchange;
}
if (typeof(ev) =3D=3D "function" ) { =20
ev =3D ev.toString();
ev =3D ev.substring(ev.indexOf("{") + 1, =
ev.lastIndexOf("}"));
}
else {
ev =3D "";
}
var func =3D new Function("ValidatorOnChange(); " + ev);
if (control.type =3D=3D "radio") {
control.onclick =3D func;
} else { =20
control.onchange =3D func;
}
}
control.Validators[control.Validators.length] =3D val;
} =20
}
function ValidatorGetValue(id) {
var control;
control =3D document.all[id];
if (typeof(control.value) =3D=3D "string") {
return control.value;
}
if (typeof(control.tagName) =3D=3D "undefined" && =
typeof(control.length) =3D=3D "number") {
var j;
for (j=3D0; j < control.length; j++) {
var inner =3D control[j];
if (typeof(inner.value) =3D=3D "string" && (inner.type !=3D =
"radio" || inner.status =3D=3D true)) {
return inner.value;
}
}
}
else {
return ValidatorGetValueRecursive(control);
}
return "";
}
function ValidatorGetValueRecursive(control)
{
if (typeof(control.value) =3D=3D "string" && (control.type !=3D =
"radio" || control.status =3D=3D true)) {
return control.value;
}
var i, val;
for (i =3D 0; i<control.children.length; i++) {
val =3D ValidatorGetValueRecursive(control.children[i]);
if (val !=3D "") return val;
}
return "";
}
function Page_ClientValidate() {
var i;
for (i =3D 0; i < Page_Validators.length; i++) {
ValidatorValidate(Page_Validators[i]);
}
ValidatorUpdateIsValid(); =20
ValidationSummaryOnSubmit();
Page_BlockSubmit =3D !Page_IsValid;
return Page_IsValid;
}
function ValidatorCommonOnSubmit() {
event.returnValue =3D !Page_BlockSubmit;
Page_BlockSubmit =3D false;
}
function ValidatorEnable(val, enable) {
val.enabled =3D (enable !=3D false);
ValidatorValidate(val);
ValidatorUpdateIsValid();
}
function ValidatorOnChange() {
var vals =3D event.srcElement.Validators;
var i;
for (i =3D 0; i < vals.length; i++) {
ValidatorValidate(vals[i]);
}
ValidatorUpdateIsValid(); =20
}
function ValidatorValidate(val) { =20
val.isvalid =3D true;
if (val.enabled !=3D false) {
if (typeof(val.evaluationfunction) =3D=3D "function") {
val.isvalid =3D val.evaluationfunction(val);=20
}
}
ValidatorUpdateDisplay(val);
}
function ValidatorOnLoad() {
if (typeof(Page_Validators) =3D=3D "undefined")
return;
var i, val;
for (i =3D 0; i < Page_Validators.length; i++) {
val =3D Page_Validators[i];
if (typeof(val.evaluationfunction) =3D=3D "string") {
eval("val.evaluationfunction =3D " + val.evaluationfunction =
+ ";");
}
if (typeof(val.isvalid) =3D=3D "string") {
if (val.isvalid =3D=3D "False") {
val.isvalid =3D false; =20
Page_IsValid =3D false;
}=20
else {
val.isvalid =3D true;
}
} else {
val.isvalid =3D true;
}
if (typeof(val.enabled) =3D=3D "string") {
val.enabled =3D (val.enabled !=3D "False");
}
ValidatorHookupControlID(val.controltovalidate, val);
ValidatorHookupControlID(val.controlhookup, val);
}
Page_ValidationActive =3D true;
}
function ValidatorConvert(op, dataType, val) {
function GetFullYear(year) {
return (year + parseInt(val.century)) - ((year < val.cutoffyear) =
? 0 : 100);
}
var num, cleanInput, m, exp;
if (dataType =3D=3D "Integer") {
exp =3D /^\s*[-\+]?\d+\s*$/;
if (op.match(exp) =3D=3D null)=20
return null;
num =3D parseInt(op, 10);
return (isNaN(num) ? null : num);
}
else if(dataType =3D=3D "Double") {
exp =3D new RegExp("^\\s*([-\\+])?(\\d+)?(\\" + val.decimalchar =
+ "(\\d+))?\\s*$");
m =3D op.match(exp);
if (m =3D=3D null)
return null;
cleanInput =3D m[1] + (m[2].length>0 ? m[2] : "0") + "." + m[4];
num =3D parseFloat(cleanInput);
return (isNaN(num) ? null : num); =20
}=20
else if (dataType =3D=3D "Currency") {
exp =3D new RegExp("^\\s*([-\\+])?(((\\d+)\\" + val.groupchar + =
")*)(\\d+)"
+ ((val.digits > 0) ? "(\\" + val.decimalchar + =
"(\\d{1," + val.digits + "}))?" : "")
+ "\\s*$");
m =3D op.match(exp);
if (m =3D=3D null)
return null;
var intermed =3D m[2] + m[5] ;
cleanInput =3D m[1] + intermed.replace(new RegExp("(\\" + =
val.groupchar + ")", "g"), "") + ((val.digits > 0) ? "." + m[7] : 0);
num =3D parseFloat(cleanInput);
return (isNaN(num) ? null : num); =20
}
else if (dataType =3D=3D "Date") {
var yearFirstExp =3D new =
RegExp("^\\s*((\\d{4})|(\\d{2}))([-./])(\\d{1,2})\\4(\\d{1,2})\\s*$");
m =3D op.match(yearFirstExp);
var day, month, year;
if (m !=3D null && (m[2].length =3D=3D 4 || val.dateorder =3D=3D =
"ymd")) {
day =3D m[6];
month =3D m[5];
year =3D (m[2].length =3D=3D 4) ? m[2] : =
GetFullYear(parseInt(m[3], 10))
}
else {
if (val.dateorder =3D=3D "ymd"){
return null; =09
} =09
var yearLastExp =3D new =
RegExp("^\\s*(\\d{1,2})([-./])(\\d{1,2})\\2((\\d{4})|(\\d{2}))\\s*$");
m =3D op.match(yearLastExp);
if (m =3D=3D null) {
return null;
}
if (val.dateorder =3D=3D "mdy") {
day =3D m[3];
month =3D m[1];
}
else {
day =3D m[1];
month =3D m[3];
}
year =3D (m[5].length =3D=3D 4) ? m[5] : =
GetFullYear(parseInt(m[6], 10))
}
month -=3D 1;
var date =3D new Date(year, month, day);
return (typeof(date) =3D=3D "object" && year =3D=3D =
date.getFullYear() && month =3D=3D date.getMonth() && day =3D=3D =
date.getDate()) ? date.valueOf() : null;
}
else {
return op.toString();
}
}
function ValidatorCompare(operand1, operand2, operator, val) {
var dataType =3D val.type;
var op1, op2;
if ((op1 =3D ValidatorConvert(operand1, dataType, val)) =3D=3D null)
return false; =20
if (operator =3D=3D "DataTypeCheck")
return true;
if ((op2 =3D ValidatorConvert(operand2, dataType, val)) =3D=3D null)
return true;
switch (operator) {
case "NotEqual":
return (op1 !=3D op2);
case "GreaterThan":
return (op1 > op2);
case "GreaterThanEqual":
return (op1 >=3D op2);
case "LessThan":
return (op1 < op2);
case "LessThanEqual":
return (op1 <=3D op2);
default:
return (op1 =3D=3D op2); =20
}
}
function CompareValidatorEvaluateIsValid(val) {
var value =3D ValidatorGetValue(val.controltovalidate);
if (ValidatorTrim(value).length =3D=3D 0)
return true;
var compareTo =3D "";
if (null =3D=3D document.all[val.controltocompare]) {
if (typeof(val.valuetocompare) =3D=3D "string") {
compareTo =3D val.valuetocompare;
}
}
else {
compareTo =3D ValidatorGetValue(val.controltocompare);
}
return ValidatorCompare(value, compareTo, val.operator, val);
}
function CustomValidatorEvaluateIsValid(val) {
var value =3D "";
if (typeof(val.controltovalidate) =3D=3D "string") {
value =3D ValidatorGetValue(val.controltovalidate);
if (ValidatorTrim(value).length =3D=3D 0)
return true;
}
var args =3D { Value:value, IsValid:true };
if (typeof(val.clientvalidationfunction) =3D=3D "string") {
eval(val.clientvalidationfunction + "(val, args) ;");
} =20
return args.IsValid;
}
function RegularExpressionValidatorEvaluateIsValid(val) {
var value =3D ValidatorGetValue(val.controltovalidate);
if (ValidatorTrim(value).length =3D=3D 0)
return true; =20
var rx =3D new RegExp(val.validationexpression);
var matches =3D rx.exec(value);
return (matches !=3D null && value =3D=3D matches[0]);
}
function ValidatorTrim(s) {
var m =3D s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
return (m =3D=3D null) ? "" : m[1];
}
function RequiredFieldValidatorEvaluateIsValid(val) {
return (ValidatorTrim(ValidatorGetValue(val.controltovalidate)) !=3D =
ValidatorTrim(val.initialvalue))
}
function RangeValidatorEvaluateIsValid(val) {
var value =3D ValidatorGetValue(val.controltovalidate);
if (ValidatorTrim(value).length =3D=3D 0)=20
return true;
return (ValidatorCompare(value, val.minimumvalue, =
"GreaterThanEqual", val) &&
ValidatorCompare(value, val.maximumvalue, "LessThanEqual", =
val));
}
function ValidationSummaryOnSubmit() {
if (typeof(Page_ValidationSummaries) =3D=3D "undefined")=20
return;
var summary, sums, s;
for (sums =3D 0; sums < Page_ValidationSummaries.length; sums++) {
summary =3D Page_ValidationSummaries[sums];
summary.style.display =3D "none";
if (!Page_IsValid) {
if (summary.showsummary !=3D "False") {
summary.style.display =3D "";
if (typeof(summary.displaymode) !=3D "string") {
summary.displaymode =3D "BulletList";
}
switch (summary.displaymode) {
case "List":
headerSep =3D "<br>";
first =3D "";
pre =3D "";
post =3D "<br>";
final =3D "";
break;
case "BulletList":
default:=20
headerSep =3D "";
first =3D "<ul>";
pre =3D "<li>";
post =3D "</li>";
final =3D "</ul>";
break;
case "SingleParagraph":
headerSep =3D " ";
first =3D "";
pre =3D "";
post =3D " ";
final =3D "<br>";
break;
}
s =3D "";
if (typeof(summary.headertext) =3D=3D "string") {
s +=3D summary.headertext + headerSep;
}
s +=3D first;
for (i=3D0; i<Page_Validators.length; i++) {
if (!Page_Validators[i].isvalid && =
typeof(Page_Validators[i].errormessage) =3D=3D "string") {
s +=3D pre + Page_Validators[i].errormessage + =
post;
}
} =20
s +=3D final;
summary.innerHTML =3D s;=20
window.scrollTo(0,0);
}
if (summary.showmessagebox =3D=3D "True") {
s =3D "";
if (typeof(summary.headertext) =3D=3D "string") {
s +=3D summary.headertext + "<BR>";
}
for (i=3D0; i<Page_Validators.length; i++) {
if (!Page_Validators[i].isvalid && =
typeof(Page_Validators[i].errormessage) =3D=3D "string") {
switch (summary.displaymode) {
case "List":
s +=3D Page_Validators[i].errormessage + =
"<BR>";
break;
case "BulletList":
default:=20
s +=3D " - " + =
Page_Validators[i].errormessage + "<BR>";
break;
case "SingleParagraph":
s +=3D Page_Validators[i].errormessage + =
" ";
break;
}
}
}
span =3D document.createElement("SPAN");
span.innerHTML =3D s;
s =3D span.innerText;
alert(s);
}
}
}
}
--Boundary_(ID_NjPBUP0BsVTvcGDepWXTxw)--