Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Ajax con C# y ASP

Estas en el tema de Ajax con C# y ASP en el foro de Frameworks JS en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 07/01/2011, 11:31
 
Fecha de Ingreso: noviembre-2008
Mensajes: 2
Antigüedad: 15 años, 6 meses
Puntos: 0
Pregunta Ajax con C# y ASP

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.vis ibility = "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.vis ibility = "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 />
  #2 (permalink)  
Antiguo 07/01/2011, 18:57
Avatar de maycolalvarez
Colaborador
 
Fecha de Ingreso: julio-2008
Ubicación: Caracas
Mensajes: 12.120
Antigüedad: 15 años, 9 meses
Puntos: 1532
Respuesta: Ajax con C# y ASP

si no te has informado bien sobre AJAX el mismo depende de javascript y javascript no tiene acceso al IO, por lo tanto no puede leer archivos del cliente y mucho menos se puede enviar el archivo a través de AJAX

la mejor opción para hacer esto es usar un iframe oculto y enviar el form por él, se puede dumpear código javascript desde asp.net-c# para acceder al DOM parent y esto en esencia es AJAX
__________________
¡Por favor!: usa el highlight para mostrar código
El que busca, encuentra...

Etiquetas: ajax, asp
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 10:08.