My problem is the next, when I put the instruccion : Response.Redirect("url") in the upload button, my program works ok, but I want to put the instruccion in a LinkButton, but when i put the instruccion in these place my program can´t find the page.
THis is my code:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="AplicacionWebPablo._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub UploadButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
' Specify the path on the server to
' save the uploaded file to.
Dim savePath As String = "c:\inetpub\wwwroot\pablo\"
' Before attempting to save the file, verify
' that the FileUpload control contains a file.
If (FileUpload1.HasFile) Then
' Get the size in bytes of the file to upload.
Dim fileSize As Integer = FileUpload1.PostedFile.ContentLength
' Allow only files less than 2,100,000 bytes (approximately 2 MB) to be uploaded.
If (fileSize < 2100000) Then
' Append the name of the uploaded file to the path.
savePath += Server.HtmlEncode(FileUpload1.FileName)
' Call the SaveAs method to save the
' uploaded file to the specified path.
' This example does not perform all
' the necessary error checking.
' If a file with the same name
' already exists in the specified path,
' the uploaded file overwrites it.
FileUpload1.SaveAs(savePath)
' Notify the user that the file was uploaded successfully.
UploadStatusLabel.Text = "Su archivo se ha subido correctamente"
Else
' Notify the user why their file was not uploaded.
UploadStatusLabel.Text = "Su archivo no se ha podido subir, debido a que excede " + _
"el límite de memoria (2MB)."
End If
Else
' Notify the user that a file was not uploaded.
UploadStatusLabel.Text = "No ha especificado el archivo a subir."
End If
LinkButton1.Text = "http://desarrollo1/pablo/" & FileUpload1.FileName
'Response.Redirect("http://desarrollo1/pablo/" & FileUpload1.FileName)
End Sub
</script>
<script runat="server">
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Redirect("http://desarrollo1/pablo/" & FileUpload1.FileName)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Ejemplo de subir archivos</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h4>
Seleccione el archivo a subir:</h4>
<asp:FileUpload id="FileUpload1"
runat="server">
</asp:FileUpload>
<br/><br/>
<asp:Button id="UploadButton"
Text="Subir Archivo"
onclick="UploadButton_Click"
runat="server">
</asp:Button>
<hr />
<asp:Label id="UploadStatusLabel"
runat="server">
</asp:Label><br />
<br />
<asp:LinkButton ID="LinkButton1" onclick="LinkButton1_Click" runat="server"></asp:LinkButton><br />
<br />
<asp:Button ID="Button1" runat="server" Text="Button" /></div>
</form>
</body>
</html>
THank you!!!

New Topic/Question
Reply




MultiQuote




|