Foros del Web » Programando para Internet » ASPX (.net) »

Upload de archivo (Se ejecuta submit atomaticamente)

Estas en el tema de Upload de archivo (Se ejecuta submit atomaticamente) en el foro de ASPX (.net) en Foros del Web. Hola, el problema es el siguiente: Tengo una aplicacion que lo que hace es subir fotos a un servidor y luego mostrarlas en un pagina ...
  #1 (permalink)  
Antiguo 22/08/2012, 16:07
 
Fecha de Ingreso: septiembre-2008
Mensajes: 14
Antigüedad: 15 años, 7 meses
Puntos: 0
Upload de archivo (Se ejecuta submit atomaticamente)

Hola, el problema es el siguiente:

Tengo una aplicacion que lo que hace es subir fotos a un servidor y luego mostrarlas en un pagina especifica.
El problema es que al momento de buscar la foto con el explorador de windows se ejecuta automaticamente el submit, no hace falta darle click al boton de enviar.
Queria ver si alguien me hecha una mano con esto, desde ya muchas gracias!


Dejo los codigos pertinentes:


EXAMINAR.ASPX

Código:
<head runat="server">
    
    <script type="text/javascript" src="/ProgramacionPaginas/RefereciasJquery/Jquery/v171/jquery.js"></script>

    <title>Nuevo Item</title>
    
    <script type="text/jscript" language="javascript">
        function __doPostBack(Target, Argument) {
            var theForm = document.getElementById("form1");
            theForm.__EVENTTARGET.value = Target;
            theForm.__EVENTARGUMENT.value = Argument;
            theForm.submit;
        };

       </script>

    <script type="text/javascript"> 
        $(function () {

            var Propiedades = document.getElementById("txtURL_Imagen");

           // Propiedades.style.visibility = "hidden";

        });
        
    </script>
   
</head>
<body>
    <form id="form1" runat="server" enctype="multipart/form-data">
    <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
    <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
            
            <asp:FileUpload runat="server" ID="upfImagen" Width="293px" onchange="javascript:__doPostBack('GuardarImagenBanner','');" />
            <asp:TextBox ID="txtURL_Imagen" runat="server" Width="28px"></asp:TextBox>
            
    </form>






FOTO.ASPX

Código:
<script type="text/VB" runat="server"> 
   
    Function Usuario(ByVal strUsuarioLogeado As String) As String
        Dim parts() As String = Split(strUsuarioLogeado, "\")
        Dim username As String = parts(1)
        Return username
    End Function
    
    Protected Function getPosicion() As String
        Dim strResultado As New StringBuilder
        
        Using objSPsite = New SPSite("http://intranet.corp.cablevision.com.ar")
            Dim objUser As SPUser = objSPsite.SystemAccount
                    
            Dim osite As New SPSite("http://intranet.corp.cablevision.com.ar", objUser.UserToken)
            objSPsite.Dispose()
            Using objSPWeb As SPWeb = osite.OpenWeb
                
                Dim list As SPList = osite.AllWebs("rrhh/ADIRH").Lists("GaleriaDeImagenesMiMascota")
                Dim listItems As SPListItemCollection = list.Items()
                Dim ds As New DataSet
            
                ds.Merge(listItems.GetDataTable.Select("", "Created desc", DataViewRowState.CurrentRows))
                
                Try
                    objSPWeb.AllowUnsafeUpdates = True
                    For Each col As DataRow In ds.Tables(0).Rows
                      
                        strResultado.Append("<div style=""background-image: url('images/Polaroid-03.png'); background-repeat: no-repeat; width: 213px; height: 270px; float: left; margin-left: 10px;"">")
                        strResultado.Append("<img id=""Grados"" src=""" + col("URLIMG").ToString + """ style=""width: 140px; height: 120px; left: 30px; top: 47px; border: 0px solid red; position: relative;"" />")
                        strResultado.Append("<div id=""" + col("ID").ToString + """ onclick=""Megusta(" + col("ID").ToString + ");"" style=""cursor:url('images/hand.cur'); width: 28px; height: 10px; left: 27px; top: 62px; border: 0px solid red; position: relative;"" ></div>")
                        strResultado.Append("<div onclick=""LeGustaA(" + col("ID").ToString + ");"" style="" cursor:url('images/hand.cur'); width: 28px; height: 10px; left: 55px; top: 40px; border: 0px solid red; position: relative; text-align:center;"" >" + col("megusta").ToString + "</div>")
                        strResultado.Append("<div style=""width: 210px; height: 10px; left: 13px; top: 62px; border: 0px solid red; position: relative;"" >")
                        strResultado.Append(col("usuario").ToString + "<br/>"+ col("Title").ToString)
                        strResultado.Append("</div>")
                        strResultado.Append("</div>")
                        
                    Next
                    objSPWeb.AllowUnsafeUpdates = False
                Catch ex As Exception
                    strResultado.Append(ex.Message)
                End Try
                
            End Using
        End Using
        Return strResultado.ToString
    End Function
    
    
    
       
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Response.Write(getPosicion())
    End Sub

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

    $(function () {
        $("#btoPublicar").click(function () {

            var frame = document.getElementById("NombreImagen");
            document.getElementById("txtLinks").value = frame.contentWindow.document.getElementById("txtURL_Imagen").value;

            var Links = document.getElementById("txtLinks").value;


            if (!$(":text").val()) {
                $("#Error").html("Es necesario completar el título.");
            } else { $("#Error").html(""); }

            if (!Links) {
                $("#Error").html("Es necesario cargar la foto.");

            } else {


                jQuery.ajax({
                    type: "POST",
                    url: "",
                    success: function (H) {

                        // Hacer un refresh de la carga de datos
                        $("#Error").html("");
                    },
                    async: true
                }); //Cierro el Ajax

            }; //Cierro el IF

        }); //Cierro el Clic
    });  //Cierro el reader

        
</script>


PUBLICAR.ASPX

Código:
<script type="text/javascript">

    $(function () {
        $("#btoPublicar").click(function () {

            var frame = document.getElementById("NombreImagen");
            document.getElementById("txtLinks").value = frame.contentWindow.document.getElementById("txtURL_Imagen").value;

            var Links = document.getElementById("txtLinks").value;


            if ((!Links) || (!$(":text").val())){
                $("#Error").html("Es necesario cargar la foto y un nombre.");
            } else {
                jQuery.ajax({
                    type: "POST",
                    url: "setFotoItem.aspx?Title=" + encodeURIComponent($(":text").val()) + "&URLIMG=" + encodeURIComponent(Links),
                    success: function (H) {

                        // Hacer un refresh de la carga de datos
                        $("#Error").html("");
                        $("#Ventana").fadeOut("show");
                        $(function () {
                            $.ajax({
                                type: "POST",
                                url: "getFotos.aspx",
                                cache: false,
                                beforeSend: function () { $("#DivContenido").load("Loading.htm"); },
                                success: function (H) { $("#DivContenido").html(H); },
                                async: true
                            }); //Cierro el Ajax
                        }); 
                    },
                    async: true
                }); //Cierro el Ajax
            }; //Cierro el IF
        }); //Cierro el Clic
    });   //Cierro el reader

Etiquetas: asp, ejecuta, javascript, net, submit, textbox, upload
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 12:43.