AJAX - duda con ajax, c# y asp

 
Vista:

duda con ajax, c# y asp

Publicado por germencita (1 intervención) el 07/01/2011 18:33:33
Hola,
Soy nueva con Ajax y estoy bastante perdida. Agradecería mucho un poco de orientación...
Utilizo ASP y C#. Necesito crear un formulario con un campo “file” donde al seleccionar un fichero (sin pulsar ningun botón), se trate ese fichero en el lado del servidor (codebehind en C#) obteniendo un string. Sin recargar la página, necesito mostrar ese string en un Textbox.
Adjunto el código del lado del cliente. Mi duda es cómo asociar este código con el C#. He supuesto que en la URL del método “GET” habría que poner la ruta del código C#, pero yo sólo necesito que me devuelva un string...
Muchas gracias de antemano.

<script language="javascript" type="text/javascript">

var http_request;

var READY_STATE_COMPLETE = 4;
var READY_STATE_UNINITIALIZED = 0;
var READY_STATE_LOADING = 1;
var READY_STATE_LOADED = 2;
var READY_STATE_INTERACTIVE = 3;

function showConfigContent() {

document.getElementById("textBoxConfig").style.visibility = "visible";

http_request = initialize_xmlHttpRequest();
//to instantiate the XMLHttpRequest object

//preparing the Response function

http_request.onreadystatechange = callback;
//without parentheses; when the app recibes the response, this function is executed

var url = "default.aspx.cs"

http_request.open("GET", url, true); // (method, URL, true)

http_request.send(null);

}

function initialize_xmlHttpRequest() {

if (window.XMLHttpRequest) {

return new XMLHttpRequest();

}
else if (window.ActiveXObject) {

return new ActiveXObject("Microsoft.XMLHTTP");
}
}

function callback() {

if (http_request.readyState == 4 && http_request.status == 200) {

document.getElementById("textBoxConfig").style.visibility = "visible";
document.getElementById("textBoxConfig").innerHTML = http_request.responseText;

}
}

</script>




<form>
<input id="file1" type="file" onchange="showConfigContent();" />
</form>
<asp:TextBox ID="textBoxConfig" Text="" runat="server" Width="600px" Visible="false" Height="500px" TextMode="multiline" Wrap=false />
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder