Bonjour,

Je débute totalement en développement de sites web, je me suis auto-formé sur les technologies ASP.Net, mais tout ça reste très nouveau et pas très clair pour moi. Merci de votre indulgence pour les énormités que je vais proférer dans la suite de ce message...

Je dois intégrer à un site dont l'architecture globale est en ASP.Net une fonctionnalité de lecture de base de donnée du SIG Manifold. Le site de ce logiciel fourni un exemple en ASP et JavaScript d'une façon de lire et modifier les tables de la base de donnée de fichiers SIG. voici le code de la page asp:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
<%@ enablesessionstate=false language=javascript %>
<%
 
// To access data using the Manifold ODBC driver (read-only), create an ODBC data source and edit the connection string below, eg:
var adoConnection = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=Nwind";
// var adoConnection = "";
 
//var mapserver = null;
var pageNo = 0; // current page
var pageSize = 16; // number of rows per page
var rowNo = 0; // current row
 
function encode(text) {
	return (text != "")? Server.HTMLEncode(text): "*";
}
 
function parameter(name, startup) {
	return (Request.Form(name).Count > 0)? Request.Form(name): startup;
}
 
function initConstraint() {
	try {
		constraint = new ActiveXObject("msxml2.DOMDocument.3.0");
		constraint.async = false;
		constraint.resolveExternals = false;
		constraint.validateOnParse = false;
		var str = "";
		str = mapserver.Document.Path;
		str = str.replace(".map", ".xml");
		constraint.load(str);
		constraint.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
		constraint.setProperty("SelectionLanguage", "XPath");
	}
	catch (e) {
		constraint = null;
	}
}
 
function isRowsetVisible(rowset) {
	if (constraint == null || constraint.documentElement == null)
		return true;
	var xpath = "";
	xpath = xpath + "rowset[@name=\'";
	xpath = xpath + rowset;
	xpath = xpath + "\']";
	return (constraint.documentElement.selectNodes( xpath ).length > 0);
}
 
function isColumnVisible(name) {
	if (constraint == null || constraint.documentElement == null)
		return true;
	var xpath = "";
	xpath = xpath + "rowset[@name=\'";
	xpath = xpath + component;
	xpath = xpath + "\']/col[@name=\'";
	xpath = xpath + name;
	xpath = xpath + "\']";
	return (constraint.documentElement.selectNodes( xpath )[0] != null);
}
 
function isColumnUpdatable(name) {
	if (constraint == null || constraint.documentElement == null)
		return true;
	var xpath = "";
	xpath = xpath + "rowset[@name=\'";
	xpath = xpath + component;
	xpath = xpath + "\']/col[@name=\'";
	xpath = xpath + name;
	xpath = xpath + "\']";
	var col = constraint.documentElement.selectNodes( xpath )[0];
	if (col == null)
		return false;
	return (col.getAttribute("edit") == "true");
}
 
function getComponent(name, page, onclick) {
	if (!isRowsetVisible(name))
		return "";
	return "<div><a href=\"#\" onclick=\"" + onclick + "(\'" + name + "\', " + page + ");\">" + encode(name) + "</a></div>";
}
 
function adoEnumRowset(table) {
	try {
		var cnt = Server.CreateObject("ADODB.Connection");
		cnt.Open(adoConnection);
		var schema = cnt.OpenSchema(20); // adSchemaTables
 
		var result = "";
		while (!schema.EOF) {
			var name = schema.Fields("TABLE_NAME");
			var type = schema.Fields("TABLE_TYPE");
			if (table && type.Value == "TABLE" || !table && type.Value != "TABLE")
				result = result + getComponent(name.Value, 0, "adoInvokeRowset");
			schema.MoveNext();
		}
		return result;
	}
	catch (e) {
        return e.message;
    }
}
 
function mfdIsTable(cmt) {
	return (cmt.Type == 13/*ComponentTable*/);
}
 
function mfdIsSelect(cmt) {
	return (cmt.Type == 11/*ComponentQuery*/ && cmt.QueryType == 9/*QueryTypeSelect*/);
}
 
function mfdIsView(cmt) {
	return (mfdIsSelect(cmt) && cmt.ParameterSet.Count == 0);
}
 
function mfdEnumRowset(table) {
	var result = "";
	var cmts = mapserver.Document.ComponentSet;
	for (nCmt = 0; nCmt < cmts.Count; nCmt++) {
		var cmt = cmts(nCmt);
		if (table && mfdIsTable(cmt))
			result = result + getComponent(cmt.Name, 0, "mfdInvokeTable");
		else if (!table && mfdIsSelect(cmt))
			result = result + getComponent(cmt.Name, 0, mfdIsView(cmt)? "mfdInvokeTable": "mfdInvokeParams");
	}
	return result;
}
 
function enumComponents() {
	var result = "";
	if (adoConnection != "") {
		result = result + "<div class=\"midheader\">Tables</div>" + adoEnumRowset(true);
		result = result + "<div class=\"midheader\">Queries</div>" + adoEnumRowset(false);
	}
	else {
		result = result + "<div class=\"midheader\">Tables</div>" + mfdEnumRowset(true);
		result = result + "<div class=\"midheader\">Queries</div>" + mfdEnumRowset(false);
	}
	return result;
}
 
function getFormReference(index) {
	return "<td><a href=\"#\" onclick=\"invokeForm(" + index + ");\">" + encode("Form") + "</a></td>";
}
 
function getCursor(active, onclick, image, name, page) {
	var result = "";
	if (active) {
		result = result + "<a href=\'#\' onclick=\"" + onclick + "(\'" + component + "\', \'" + page + "\');\">";
		result = result + "<img src=\"images/" + image + "\" alt=\"" + name + "\" title=\"" + name + "\" border=\"0\"></a>";
	}
	else
		result = result + "<img src=\"images/" + image + "\" border=\"0\">";
	return result;
}
 
function getCursorPage(active, onclick, page, last) {
	var result = "";
	if (active)
		result = result + "Page <input type=\"text\" value=\"" + (page+1) + "\" onkeydown=\"if (ie) evt=event; if (evt.keyCode==13) " + onclick + "(\'" + component + "\', null);\" name=\"pageNav\" id=\"pageNav\" style=\"width:30pt\">";
	else
		result = result + "Page " + (page+1);
	if (last >= 0)
		result = result + " of " + (last+1);
	return result;
}
 
function getCursors(onclick, prev, next, curr, last) {
	var result = "";
	result = result + "<div>";
	result = result + getCursor(prev, onclick, prev? "GoFirst.gif": "GoFirstD.gif", "First Page", 0);
	result = result + getCursor(prev, onclick, prev? "GoPrevious.gif": "GoPreviousD.gif", "Previous Page", curr - 1);
	result = result + getCursor(next, onclick, next? "GoNext.gif": "GoNextD.gif", "Next Page", curr + 1);
	if (last >= 0)
		result = result + getCursor(next, onclick, next? "GoLast.gif": "GoLastD.gif", "Last Page", last);
	result = result + " " + getCursorPage(prev || next, onclick, curr, last);
	result = result + "</div>";
	return result;
}
 
function adoIsBinary(col) {
	return (col.Type == 128/*adBinary*/ || col.Type == 204/*adVarBinary*/ || col.Type == 205/*adLongVarBinary*/);
}
 
function adoRowset() {
	pageNo = new Number(page);
 
	var cnt = Server.CreateObject("ADODB.Connection");
	cnt.Open(adoConnection);
	var nAffected = 0;
	var quantified = "[" + component + "]";
	var rs = cnt.Execute(quantified, nAffected, 2/*adCmdTable*/);
	var result = "";
 
	result = result + "<table cellpadding=\"2pt\" cellspacing=\"0\" id=\"rowset\" name=\"rowset\"><thead><tr><th></th>";
 
	var cols = rs.Fields;
	for (nCol = 0; nCol < cols.Count; nCol++) {
		var col = cols.Item(nCol);
		if (!isColumnVisible(col.Name) || adoIsBinary(col))
			continue;
		result = result + "<th>" + encode(col.Name) + "</th>";
	}
 
	result = result + "</tr></thead><tbody>";
 
	var next = false;
	var prev = false;
	var index = 0;
	while (!rs.EOF) {
		if (index >= (pageNo + 1) * pageSize) {
			next = true;
			break;
		}
		if (index >= pageNo * pageSize) {
			result = result + (index%2? "<tr>": "<tr class=\"alt\">");
			result = result + getFormReference(index);
			for (nCol = 0; nCol < cols.Count; nCol++) {
				var col = cols.Item(nCol);
				if (!isColumnVisible(col.Name) || adoIsBinary(col))
					continue;
				result = result + "<td>";
				try {
					result = result + encode(col.Value);
				}
				catch (e) {
				}
				result = result + "</td>";
			}
			result = result + "</tr>";
		}
		else
			prev = true;
		rs.MoveNext();
		index++;
	}
 
	result = result + "</tbody></table>";
	result = result + "<br>" + getCursors("adoInvokeRowset", prev, next, pageNo, -1);
    return result;
}
 
function mfdGetTable() {
	var cmts = mapserver.Document.ComponentSet;
	nCmt = cmts.ItemByName(component);
	var cmt = cmts.Item(nCmt);
	if (mfdIsTable(cmt))
		return cmt;
	else if (mfdIsView(cmt)) {
		cmt.RunEx(false);
		return cmt.Table;
	}
	else if (mfdIsSelect(cmt)) {
		Application.Lock();
 
		var doc = new ActiveXObject("msxml2.DOMDocument.3.0");
		doc.async = false;
		doc.resolveExternals = false;
		doc.validateOnParse = false;
		doc.loadXML( parameters );
		doc.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
		doc.setProperty("SelectionLanguage", "XPath");
		var values = doc.documentElement.selectNodes("param");
		var params = cmt.ParameterSet;
 
		for (nParam = 0; nParam < params.Count; nParam++)
			params.Item(nParam).Value = values[nParam].text;
 
		cmt.RunEx(false);
		return cmt.Table;
	}
	return null;
}
 
function mfdReleaseTable() {
	var cmts = mapserver.Document.ComponentSet;
	nCmt = cmts.ItemByName(component);
	var cmt = cmts.Item(nCmt);
	if (mfdIsSelect(cmt) && !mfdIsView(cmt))
		Application.UnLock();
}
 
function mfdTable(tbl) {
	pageNo = new Number(page);
 
	var result = "";
	result = result + "<table cellpadding=\"2pt\" cellspacing=\"0\" id=\"rowset\" name=\"rowset\"><thead><tr><th></th>";
 
	var cols = tbl.ColumnSet;
	for (nCol = 0; nCol < cols.Count; nCol++) {
		var col = cols(nCol);
		if (!isColumnVisible(col.Name) || col.IsTypeBinary())
			continue;
		result = result + "<th>";
		result = result + encode(col.Name);
		result = result + "</th>";
	}
 
	result = result + "</tr></thead><tbody>";
 
	var next = false;
	var prev = pageNo > 0;
	var rows = tbl.RecordSet;
	for (var index = pageNo * pageSize; index < rows.Count; index++) {
		if (index >= (pageNo + 1) * pageSize) {
			next = true;
			break;
		}
		result = result + (index%2? "<tr>": "<tr class=\"alt\">");
		result = result + getFormReference(index);
		var row = rows(index);
		for (nCol = 0; nCol < cols.Count; nCol++) {
			var col = cols(nCol);
			if (!isColumnVisible(col.Name) || col.IsTypeBinary())
				continue;
			result = result + "<td>";
			try {
				result = result + encode(row.DataText(col));
			}
			catch (e) {
			}
			result = result + "</td>";
		}
		result = result + "</tr>";
	}
 
	result = result + "</tbody></table>";
	result = result + "<br>" + getCursors("mfdInvokeTable", prev, next, pageNo, Math.ceil(rows.Count / pageSize) - 1);
    return result;
}
 
function getRow() {
	// data
	var doc = new ActiveXObject("msxml2.DOMDocument.3.0");
	doc.async = false;
	doc.resolveExternals = false;
	doc.validateOnParse = false;
	doc.loadXML(xml);
	doc.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
	doc.setProperty("SelectionLanguage", "XPath");
 
	var result = "";
 
	// html
	var row = doc.documentElement;
	var cmd = row.getAttribute("command");
 
	bUpdate = false;
	var cells = doc.documentElement.selectNodes("cell");
	result = result + "<table cellpadding=\"2pt\" cellspacing=\"0\" id=\"formRow\" name=\"formRow\">";
	result = result + "<thead><tr><th>Column</th><th>Value</th></tr></thead><tbody>";
	for (nItem = 0; nItem < cells.length; nItem++) {
		var name = cells[nItem].childNodes[0].text;
		result = result + "<tr><td>" + encode(name) + "</td><td>";
 
		var val = cells[nItem].childNodes[1].text;
		if (isColumnUpdatable(name)) {
			bUpdate = true;
			result = result + "<input type=\"text\" value=\"" + encode(val) + "\" style=\"width:320pt\">";
		}
		else
			result = result + encode(val);
 
		result = result + "</td></tr>";
	}
	//if (cmd == "mfdTable" && bUpdate)
		result = result + "<tr><td></td><td><input type=\"button\" value=\"Update\" onclick=\"invokeUpdate();\"></td>";
	result = result + "</tbody></table>";
 
	return result;
}
 
function mfdParams() {
	var cmts = mapserver.Document.ComponentSet;
	nCmt = cmts.ItemByName(component);
	var qry = cmts.Item(nCmt);
	var params = qry.ParameterSet;
 
	var result = "";
	result = result + "<table cellpadding=\"2pt\" cellspacing=\"0\" id=\"formParams\" name=\"formParams\">";
	result = result + "<thead><tr><th>Parameter</th><th>Value</th></tr></thead><tbody>";
 
	for (nItem = 0; nItem < params.Count; nItem++) {
		var param = params.Item(nItem);
		result = result + "<tr><td>" + encode(param.Name) + "</td>";
		result = result + "<td><input type=\"text\" value=\"" + encode(param.Value) + "\" style=\"width:320pt\"></td></tr>";
	}
 
	result = result + "<tr><td></td><td><input type=\"button\" value=\"Select\" onclick=\"invokeSelect();\"></td></tr>";
	result = result + "</tbody></table>";
	return result;
}
 
function mfdUpdate(tbl) {
	var doc = new ActiveXObject("msxml2.DOMDocument.3.0");
	doc.async = false;
	doc.resolveExternals = false;
	doc.validateOnParse = false;
	doc.loadXML(xml);
	doc.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
	doc.setProperty("SelectionLanguage", "XPath");
	var row = tbl.RecordSet( doc.documentElement.getAttribute("value") );
	var cells = doc.documentElement.selectNodes("cell");
 
	// check
	for (nItem = 0; nItem < cells.length; nItem++) {
		var col = cells[nItem].childNodes[0].text;
		var curValue = "";
		try {
			curValue = row.DataText( col );
		}
		catch (e) {
		}
		var oldValue = cells[nItem].childNodes[1].text;
		if (oldValue != curValue)
			return;
	}
 
	// set
	bSave = false;
	for (nItem = 0; nItem < cells.length; nItem++) {
		var col = cells[nItem].childNodes[0].text;
		var newValue = cells[nItem].childNodes[2].text;
		var oldValue = cells[nItem].childNodes[1].text;
 
		if (newValue != oldValue)
			try {
				row.Data(col) = newValue;
				bSave = true;
			}
			catch (e) {
			}
	}
	// todo: if (bSave)
	//	mapserver.Document.Save();
}
 
var command = parameter("command", "");
var commandRowset = parameter("commandRowset", "");
var component = parameter("component", "");
var parameters = parameter("parameters", "");
var page = parameter("page", 0);
var xml = parameter("xml", "");
 
var mapserver = Server.CreateObject("Manifold.MapServer");
mapserver.Create(Server.MapPath("config.txt"), parameter("state", ""), Server);
 
var title = "mapserver.Title;"
var subtitle = "mapserver.Subtitle;"
 
var constraint = null;
initConstraint();
 
var reader = "";
if (command == "adoRowset") {
	commandRowset = command;
	reader = adoRowset();
}
else if (command == "mfdTable") {
	commandRowset = command;
	try {
		reader = mfdTable(mfdGetTable());
	}
	finally {
		mfdReleaseTable();
	}
}
else if (command == "mfdParams") {
	commandRowset = command;
	reader = mfdParams();
}
else if (command == "row")
	reader = getRow();
else if (command == "update") {
	try {
		var tbl = mfdGetTable();
		mfdUpdate(tbl);
		reader = mfdTable(tbl);
		command = "mfdTable";
	}
	finally {
		mfdReleaseTable();
	}
}
else
	reader = enumComponents();
 
mapserver = null;
constraint = null;
 
%>
 
<html>
<head>
<title><%= encode(title) %></title>
<script type="text/javascript" language="javascript">
<!--
 
var opera = (navigator.userAgent.indexOf("Opera") >= 0)? true: false;
var ie = (document.all && !opera)? true: false;
 
function reload() {
	document.forms[0].submit();
}
 
function locateElement(name) {
	var element;
	if (document.getElementById)
		element = document.getElementById(name);
	else if (document.all)
		element = document.all[name];
	else if (document.layers) {
		for (var i = 0; i < document.forms[0].length; i++) {
			if (document.forms[0].elements[i].name == name) {
				element = document.forms[0].elements[i];
				break;
			}
		}
	}
	return element;
}
 
function modifyHidden(name, value) {
	var hidden = locateElement(name);
	if (hidden == null)
		return null;
	hidden.value = value;
}
 
function invoke(cmd, cmt, pg) {
	modifyHidden("command", cmd);
	modifyHidden("component", cmt);
	modifyHidden("page", pg);
	modifyHidden("xml", "");
	reload();
}
 
function invokeMain() {
	invoke("", "", "");
}
 
function resolvePage(pg) {
	if (pg == null) {
		var pgEdit = locateElement("pageNav");
		if (pgEdit != null) {
			pg = parseInt(pgEdit.value);
			if (isNaN(pg))
				pg = null;
			else
				pg--;
		}
	}
	return pg;
}
 
function adoInvokeRowset(name, pg) {
	pg = resolvePage(pg);
	if (pg != null)
		invoke("adoRowset", name, pg);
}
 
function mfdInvokeTable(name, pg) {
	pg = resolvePage(pg);
	if (pg != null)
		invoke("mfdTable", name, pg);
}
 
function mfdInvokeParams(name, pg) {
	pg = resolvePage(pg);
	if (pg != null)
		invoke("mfdParams", name, pg);
}
 
function invokeForm(index) {
	pageNo = new Number(locateElement("page").value);
	rowNo = new Number(index);
	rowNo++;
	var table = locateElement("rowset");
 
	var xml = "";
	xml = xml + "<row value=\'";
	xml = xml + index;
	xml = xml + "\' command =\'<%= command %>\'>";
	for (nItem = 1, nItems = table.rows[0].cells.length; nItem < nItems; nItem++) {
		xml = xml + "<cell><name>";
		xml = xml + table.rows[0].cells[nItem].innerHTML;
		xml = xml + "</name><value>";
		xml = xml + table.rows[rowNo - pageNo * "<%= pageSize %>"].cells[nItem].innerHTML;
		xml = xml + "</value></cell>";
	}
	xml = xml + "</row>";
 
	modifyHidden("command", "row");
	modifyHidden("xml", xml);
	reload();
}
 
function invokeUpdate() {
	var doc = null;
	var row = null;
	var cells = null;
	if (ie) {
		doc = new ActiveXObject("msxml2.DOMDocument.3.0");
		doc.async = false;
		doc.validateOnParse = false;
		doc.loadXML( locateElement("xml").value );
		doc.setProperty("SelectionNamespaces", "xmlns:xsl='http://www.w3.org/1999/XSL/Transform'");
		doc.setProperty("SelectionLanguage", "XPath");
 
		row = doc.documentElement;
		cells = doc.documentElement.selectNodes("cell");
	} else {
		var parser = new DOMParser();
		doc = parser.parseFromString(locateElement("xml").value, "text/xml");
		row = doc.documentElement;
		cells = doc.getElementsByTagName("cell");
	}
 
	var table = locateElement("formRow");
 
	var xml = "";
	xml = xml + "<row value=\'";
	xml = xml + row.getAttribute("value");
	xml = xml + "\'>";
	for (nItem = 0; nItem < cells.length; nItem++) {
		var name = cells[nItem].firstChild.firstChild.nodeValue;
		var oldValue = cells[nItem].childNodes[1].firstChild.nodeValue;
		var td = table.rows[nItem + 1].cells[1];
		var newValue = (td.childNodes.length > 0)? td.firstChild.value: td.innerHTML;
 
		xml = xml + "<cell><name>";
		xml = xml + name;
		xml = xml + "</name><old>";
		xml = xml + oldValue;
		xml = xml + "</old><new>";
		xml = xml + newValue;
		xml = xml + "</new></cell>";
	}
	xml = xml + "</row>";
 
	modifyHidden("command", "update");
	modifyHidden("xml", xml);
	reload();
}
 
function invokeSelect() {
	var table = locateElement("formParams");
	var rows = table.rows;
 
	var params = "";
	params = params + "<params>";
	for (nItem = 0; nItem < rows.length - 1; nItem++) {
		var td = rows[nItem + 1].cells[1];
		var param = td.firstChild.value;
 
		params = params + "<param>";
		params = params + param;
		params = params + "</param>";
	}
	params = params + "</params>";
	modifyHidden("parameters", params);
 
	mfdInvokeTable(locateElement("component").value, 0);
}
 
// -->
</script>
<link rel="stylesheet" type="text/css" href="default.css"></link>
</head>
 
<body link="black" vlink="black" alink="black" language="javascript">
<form action="default.asp" method="post">
<table>
 
	<!-- header -->
	<tr><td class="header">
		<a href="#" onclick="invokeMain();"><%= encode(title == ""? "Main": title) %></a>
		<% if (component != "") { %>
			- <a href="#" onclick="invoke('<%= commandRowset %>', '<%= component %>', 0);"><%= component %></a>
		<% } %>
	</td></tr>
 
	<!-- subheader -->
	<% if (subtitle != "") { %>
	<tr><td class="subheader"><%= encode(subtitle) %></td></tr>
	<% } %>
 
	<!-- data -->
	<tr><td>
		<input id="command" name="command" type="hidden" value="">
		<input id="commandRowset" name="commandRowset" type="hidden" value="<%= commandRowset %>">
		<input id="component" name="component" type="hidden" value="<%= component %>">
		<input id="parameters" name="parameters" type="hidden" value="<%= parameters %>">
		<input id="page" name="page" type="hidden" value="<%= page %>">
		<input id="xml" name="xml" type="hidden" value="<%= xml %>">
 
			<br>
		<%= reader %>
	</td></tr>
 
</table>
</form>
</body>
</html>
(disponible là : http://www.manifold.net/downloads/IMS_prog_examples.zip exemple 'Tables')

J'aimerai pouvoir reprendre ce code dans des pages basés sur du ASP.Net et utiliser l'environnement de développement de Visual Studio. Le problème est que je n'arrive pas à coller ce code dans un fichier .aspx: une foule d'erreur apparaissent et je ne comprends pas comment les régler.

De ce que je crois comprendre le code de cette page est structuré de la façon suivante:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
 
 
<%@ enablesessionstate=false language=javascript %>
<%
 
"plein de fonctions et de variables en javascript, certaines fonctions (parmi les plus importantes) retournent des string contenant du code HMTL. "
 
%>
 
<html>
<head>
<title><%= encode(title) %></title>
<script type="text/javascript" language="javascript">
 
"d'autre fonctions en javascript"
 
</script>
<link rel="stylesheet" type="text/css" href="default.css"></link>
</head>
 
<body link="black" vlink="black" alink="black" language="javascript">
<form action="default.asp" method="post">
<table>
 
	<!-- header -->
	<tr><td class="header">
		<a href="#" onclick="invokeMain();"><%= encode(title == ""? "Main": title) %></a>
		<% if (component != "") { %>
			- <a href="#" onclick="invoke('<%= commandRowset %>', '<%= component %>', 0);"><%= component %></a>
		<% } %>
	</td></tr>
 
	<!-- subheader -->
	<% if (subtitle != "") { %>
	<tr><td class="subheader"><%= encode(subtitle) %></td></tr>
	<% } %>
 
	<!-- data -->
	<tr><td>
		<input id="command" name="command" type="hidden" value="">
		<input id="commandRowset" name="commandRowset" type="hidden" value="<%= commandRowset %>">
		<input id="component" name="component" type="hidden" value="<%= component %>">
		<input id="parameters" name="parameters" type="hidden" value="<%= parameters %>">
		<input id="page" name="page" type="hidden" value="<%= page %>">
		<input id="xml" name="xml" type="hidden" value="<%= xml %>">
 
			<br>
		<%= reader %>
	</td></tr>
 
</table>
</form>
</body>
</html>
J'en appelle à votre aide pour savoir comment je peux inclure ce code dans une page .apsx vierge telle que générée par défaut par visual studio. Quand je colle les parties de ce code dans le code source de ma page default.aspx visual studio n'arrive pas à reconnaitre les fonctions javascript et me trouve plein d'erreur de syntaxte alors que ce code marche (presque) parfaitement en asp.

Ou bien pensez vous qu'il vaut mieux que mes pages d'accès en asp.net redirigent vers cette page en .asp quitte à mélanger dans mon site web final du asp et asp.net? Dans ce cas où dois-je mettre le fichier .asp et ses fichiers associés dans l'arborescence de mon projet asp.net?

Merci par avance de votre aide

Corentin