6 Replies - 5891 Views - Last Post: 22 October 2009 - 06:17 AM Rate Topic: -----

#1 Pablo3728   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 13-October 09

VB.net Web Application

Post icon  Posted 21 October 2009 - 07:44 AM

Hello! Well I have a ASP.NET web application in VB.NET 2005,I wanto to o a simple exercice. I put in the form one input file and a button.
I want to upload the file that I looked using my input file, doing click in my button. I am beginner wiht web pages and i have not got idea which is the code and where i have to put it.

Some Idea??

Thank you! :)

Pablo

This post has been edited by Pablo3728: 21 October 2009 - 07:47 AM


Is This A Good Question/Topic? 0
  • +

Replies To: VB.net Web Application

#2 SixOfEleven   User is offline

  • Planeswalker
  • member icon

Reputation: 1055
  • View blog
  • Posts: 6,643
  • Joined: 18-October 08

Re: VB.net Web Application

Posted 21 October 2009 - 07:52 AM

Off to ASP.NET.
Was This Post Helpful? 0
  • +
  • -

#3 Pablo3728   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 13-October 09

Re: VB.net Web Application

Posted 21 October 2009 - 08:07 AM

I didn't understand you
Was This Post Helpful? 0
  • +
  • -

#4 MacAnimeGirl   User is offline

  • D.I.C Regular

Reputation: 9
  • View blog
  • Posts: 282
  • Joined: 30-September 08

Re: VB.net Web Application

Posted 21 October 2009 - 10:40 AM

View PostPablo3728, on 21 Oct, 2009 - 07:07 AM, said:

I didn't understand you

He's basically telling you the post is being moved to ASP.NET.

I couldn't really understand your problem. Can you clarify?
Was This Post Helpful? 0
  • +
  • -

#5 Jayman   User is offline

  • Student of Life
  • member icon

Reputation: 423
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: VB.net Web Application

Posted 21 October 2009 - 05:26 PM

You are going to want to check into using the FileUpload control.

You can find a tutorial here to get you started.
Was This Post Helpful? 1
  • +
  • -

#6 motcom   User is offline

  • D.I.C Lover
  • member icon

Reputation: 293
  • View blog
  • Posts: 1,371
  • Joined: 16-June 08

Re: VB.net Web Application

Posted 21 October 2009 - 11:18 PM

Hi Pablo

As Jayman said, you should look into the FileUploadControl.

Here is the code i got from the MSDN for the FileUploadControl. (it also limits the file size for the upload).


<%@ Page Language="VB" %>

<!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:\temp\uploads\"

		' 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 = "Your file was uploaded successfully."

			Else
				' Notify the user why their file was not uploaded.
				UploadStatusLabel.Text = "Your file was not uploaded because " + _
										 "it exceeds the 2 MB size limit."
			End If

		Else
			' Notify the user that a file was not uploaded.
			UploadStatusLabel.Text = "You did not specify a file to upload."
		End If

	End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
	<title>FileUpload Class Example</title>
</head>
<body>
	<form id="form1" runat="server">
	<div>
	   <h4>Select a file to upload:</h4>

	   <asp:FileUpload id="FileUpload1"				 
		   runat="server">
	   </asp:FileUpload>

	   <br/><br/>

	   <asp:Button id="UploadButton" 
		   Text="Upload file"
		   onclick="UploadButton_Click"
		   runat="server">
	   </asp:Button>

	   <hr />

	   <asp:Label id="UploadStatusLabel"
		   runat="server">
	   </asp:Label>

	</div>
	</form>
</body>
</html>



Was This Post Helpful? 1
  • +
  • -

#7 Pablo3728   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 13-October 09

Re: VB.net Web Application

Posted 22 October 2009 - 06:17 AM

Thank you for all! I will read the tutorials!

:)

Pablo
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1