Private Sub gv_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvPropuestasDiagnosticoListar.RowCreated
Dim imgRespuesta As New ImageButton
Dim fupRespuesta As New FileUpload
imgRespuesta = e.Row.FindControl("imgProDiagUploadRespuesta")
fupRespuesta = e.Row.FindControl("fupvcProDiaRutaRespuesta")
If Not imgRespuesta Is Nothing And Not fupRespuesta Is Nothing Then
AddHandler imgRespuesta.Click, AddressOf img_Click
'imgRespuesta.Attributes.Add("Style", "Display:none")
'fupRespuesta.Attributes.Add("onchange", "return document.getElementById('" + imgRespuesta.ClientID + "').click();")
End If
End Sub
Private Sub img_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
Dim fup As FileUpload
Dim img As ImageButton
fup = CType(sender.Parent.Parent, GridViewRow).FindControl("fupvcProDiaRutaPropuesta")
img = CType(sender.Parent.Parent, GridViewRow).FindControl("imgProDiagUploadPropuesta")
If fup.HasFile = True Then
img.Attributes.Remove("Style")
Dim fullpath = IO.Path.GetFullPath(fup.FileName)
Dim name = IO.Path.GetFileName(fullpath)
fup.SaveAs(Server.MapPath("~") + "\Documentos\" & name.ToString)
End If
End Sub
Re: FileUpload automatically upload after set filepath
Write the following code in RowDataBound event of the GridView control. This code is to attach onChange event of the file upload control to the click event of image button control.
Re: FileUpload automatically upload after set filepath
I tried it, and it reaches the event, as you said, but the problem now is that the HasFile property of the FileUpload control is false when after I select the file... And I don't know why...
Private Sub imgEnvio_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs)
Dim fup As FileUpload
Dim img As ImageButton
fup = CType(sender.Parent.Parent, GridViewRow).FindControl("fupvcProDiaRutaPropuesta")
img = CType(sender.Parent.Parent, GridViewRow).FindControl("imgProDiagUploadPropuesta")
If fup.HasFile Then <-- this is not true after I select the file
img.Attributes.Remove("Style")
Dim fullpath = IO.Path.GetFullPath(fup.FileName)
Dim name = IO.Path.GetFileName(fullpath)
fup.SaveAs(Server.MapPath("~") + "\Documentos\" & name.ToString)
End If
End Sub
Write the following code in RowDataBound event of the GridView control. This code is to attach onChange event of the file upload control to the click event of image button control.
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.