Jump to content
Xtreme .Net Talk

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


Recommended Posts

Posted

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

Posted

First I answer point 2, the rest maybe tomorrow (it is 00:20 and I must work tomorrow...) and I'm C# programmer, but cast it to VB should not too hard...

 

For HTTP-Upload your form must have this attributes:

<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 framework's directory on your hdd!

 

The InputFileField must look like this (and it must inside the form-tags)

<INPUT id="File1" type="file" name="File1" runat="server">

 

That's all for the HTML part... go on to serverside...

 

1. Upload File

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

File1.PostedFile.SaveAs(FileNameOnServer);

 

2. Create Bitmap

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

Posted

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: I'm sure anotherone helps you gladly!

 

Greeetz!

-WebJumper

Posted
Hi WebJumper. When uploading and convertig file to bitmap you don't 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).

A man and a dog have an average of three legs.

Beaware of Statistics.

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...