Hello everyone, I tried toswitch to ajavascript function server-sideinformation.The problem seems tobe dueto the factthat he can notread the valueof theJavaScriptvariable "filename" (it is notseen in the context )in thefollowing code:
<script> var selDiv = ""; document.addEventListener("DOMContentLoaded", init, false); function init() { document.querySelector('#files').addEventListener('change', handleFileSelect, false); selDiv = document.querySelector("#selectedFiles"); } function handleFileSelect(e) { if (!e.target.files) return; var html = "<table class=\"table table-striped\"><thead><tr>"; html += "<th>#</th>"; html += "<th>File Name</th>"; html += "<th>Type</th>"; html += "<th>Size</th>"; html += "<th>Last Modified Date</th>"; html += "<th>Note</th>"; html += "</tr>"; html += "</thead>"; html += "<tbody>"; var files = e.target.files; var isCorrectFile = false; for (var i = 0; i < files.length; i++) { var f = files[i]; var filename = f.name; isCorrectFile = false; @foreach (Dictionary< string, object> dicFileName in ViewData["CsvNamesList"] as List<Dictionary<string, object>>) {<text> if (filename == "@dicFileName["ImportFileName"]") { isCorrectFile = true; break; } else { isCorrectFile = false; }</text> } if (isCorrectFile) { html += "<tr>"; html += "<th scope=\"row\">" + (i + 1) + "</th>" html += "<td>" + f.name + "</td>"; html += "<td>" + f.type + "</td>"; html += "<td>" + (f.size / 1000).toFixed(2).toString().replace('.', ',') + " KB" + "</td>"; html += "<td>" + f.lastModifiedDate.toLocaleDateString() + "</td>"; html += "<td>" + "" + "</td>"; html += "<tr/>"; } else { html += "<tr class=\"warning\" >"; html += "<th scope=\"row\">" + (i + 1) + "</th>" html += "<td>" + f.name + "</td>"; html += "<td>" + f.type + "</td>"; html += "<td>" + (f.size / 1000).toFixed(2).toString().replace('.', ',') + " KB" + "</td>"; html += "<td>" + f.lastModifiedDate.toLocaleDateString() + "</td>"; html += "<td>" + "Nome del file non ammesso nel IMPORT" + "</td>"; html += "<tr/>"; } } html += "</tbody>"; html += "</table>"; selDiv.innerHTML = html; }</script>
Basicallywhen I manage toblock the executionwithbreakpoint I can readthe values of "@dicFileName["ImportFileName"]"and notthose of"filename"and"isCorrectName" variabledoes not goto "true"even if itshould. Paolo