So I have a problem with ASP.Net and JavaScript.
The problem is this:
I am wanting to write the value of the upload form field in the popup window to a textbox.
i realized due to security you cant write the value of the file upload field in a client side function and if you do it returns c:/fakepath/realfilename.extention which is what is happening with me. It has to be done with server side code. At the moment I have a JavaScript function doing it Called WriteTextBoxValue. I'm wondering how I can alter my code or logic to make it so that it can write the file upload text to it. Keep in mind the popup needs to know which textbox to write the value in which is why I've passed the reference to the textbox in the ShowControl function.
I have a simple div popup window which i show with a click of a button using the ShowControl function I have created. The popup has an asp file upload field and an asp textbox. The popup window and button are on the same page.
This Code below is like what i have on 1 asp.net page:
var selectedUploadField;
function ShowControl(controlName){
var upControl = document.getElementById("divUploadControl");
upControl.style.display = "block";
selectedUploadField = controlName;
}
Script that writes the value of the file upload field to the textbox associated with the button that was clicked:
function WriteTextBoxValue(){
var txtControl = document.getElementById(selectedUploadField);
var fileUploadControl = document.getElementById("<%= fileUploadForm.ClientID %>");
txtControl.value = fileUploadControl.value;
document.getElementById("divUploadControl").style.display = "none";
return false;
}
Bookmarks