Couple of questions, FTP upload, Image resizeing, and datagrid paging

justjosh

New member
Joined
Jul 9, 2003
Messages
3
Location
Arizona
Couple of questions:

1) Is there a good site that can help me create an asp.net page to upload files to an FTP server

2) I need to be able to have somebody upload an image to me, then will want to convert it to jpg, and resize the image. Any sites you could direct me to for this?

3) K, last but not least, I have a search that pulls data from an SQL Query and sticks the results in a datagrid. I have set the code to change the page to be:

Private Sub MyDataGrid_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles MyDataGrid.PageIndexChanged

MyDataGrid.CurrentPageIndex = e.NewPageIndex
MyDataGrid.DataBind()

End Sub

When I click "next page" it clears the datagrid, and when I click on the "search" button again it will show the next page.

One last thing, I have two radio buttons on another page that I want it to swap some text when I switch the two. But it has no effect when I switch the radio buttons.

Here is the code:

Private Sub Radio2_Radio_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Radio2_Radio.CheckedChanged

TestA_Checkbox.Visible = True

TestB_Checkbox.Text = "Some new text"


End Sub


I am using Visual Studio .Net 2003, with VB.NET Source.

any help would be GREATLY appreciated
 
First I answer point 2, the rest maybe tomorrow (it is 00:20 and I must work tomorrow...) and Im C# programmer, but cast it to VB should not too hard...

For HTTP-Upload your form must have this attributes:
Code:
<form id="Form1" method="post" encType="multipart/form-data" runat="server">
Consider that you can only upload 4MB data. If you want upload more data you have to change the machine.config in the frameworks directory on your hdd!

The InputFileField must look like this (and it must inside the form-tags)
Code:
<INPUT id="File1" type="file" name="File1" runat="server">

Thats all for the HTML part... go on to serverside...

1. Upload File
Code:
string FileNameOnServer = @"C:\" + File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf(@"\")+1);

File1.PostedFile.SaveAs(FileNameOnServer);

2. Create Bitmap
Code:
System.Drawing.Image sourceImg = System.Drawing.Image.FromFile(FileNameOnServer);

System.Drawing.Bitmap destinationImg = new System.Drawing.Bitmap(sourceImg, new System.Drawing.Size(400, 200));
			
destinationImg.Save(@"C:\Test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

sourceImg.Dispose();
destinationImg.Dispose();

Good luck to convert to VB!

Regards, Stefan
 
DataGrid problem: seems that your DataSource get lost. By clicking Search-Button i think you execute the SQL Query und set DataGrid.DataSource = myDataTable; or something...
Hold the search results (DataTable) in a session and when the page do a postback acollate it to the datasource of the grid. Then the paging should work!

RadioButtons: AutoPostBack must set to TRUE !!!!


FTP problem: Im sure anotherone helps you gladly!

Greeetz!
-WebJumper
 
Hi WebJumper. When uploading and convertig file to bitmap you dont have to save your file on server, because this file "comes" as a stream. Than you can create a bitmap directly from that stream (one of the overloaded constructors).
 
Thank you very much for your help, I havnt gotten to the point of testing ftp/image part, but the paging and radio buttons are working now, thanks!
 
Back
Top