Click here to Skip to main content
16,004,727 members

S.Dhanasekaran - Professional Profile



Summary

Follow on Twitter      Blog RSS
180
Authority
3
Debator
7
Enquirer
168
Organiser
1,056
Participant
0
Author
0
Editor
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Reputation

Weekly Data. Recent events may not appear immediately. For information on Reputation please see the FAQ.

Privileges

Members need to achieve at least one of the given member levels in the given reputation categories in order to perform a given action. For example, to store personal files in your account area you will need to achieve Platinum level in either the Author or Authority category. The "If Owner" column means that owners of an item automatically have the privilege. The member types column lists member types who gain the privilege regardless of their reputation level.

ActionAuthorAuthorityDebatorEditorEnquirerOrganiserParticipantIf OwnerMember Types
Have no restrictions on voting frequencysilversilversilversilver
Bypass spam checks when posting contentsilversilversilversilversilversilvergoldSubEditor, Mentor, Protector, Editor
Store personal files in your account areaplatinumplatinumSubEditor, Editor
Have live hyperlinks in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Have the ability to include a biography in your profilebronzebronzebronzebronzebronzebronzesilverSubEditor, Protector, Editor
Edit a Question in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Edit an Answer in Q&AsilversilversilversilverYesSubEditor, Protector, Editor
Delete a Question in Q&AYesSubEditor, Protector, Editor
Delete an Answer in Q&AYesSubEditor, Protector, Editor
Report an ArticlesilversilversilversilverSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending ArticlegoldgoldgoldgoldSubEditor, Mentor, Protector, Editor
Edit other members' articlesSubEditor, Protector, Editor
Create an article without requiring moderationplatinumSubEditor, Mentor, Protector, Editor
Approve/Disapprove a pending QuestionProtector
Approve/Disapprove a pending AnswerProtector
Report a forum messagesilversilverbronzeProtector, Editor
Approve/Disapprove a pending Forum MessageProtector
Have the ability to send direct emails to members in the forumsProtector
Create a new tagsilversilversilversilver
Modify a tagsilversilversilversilver

Actions with a green tick can be performed by this member.


 
QuestionWinform UploadFile to Upload.aspx page (VB.Net 2005) Pin
S.Dhanasekaran5-Oct-09 23:57
S.Dhanasekaran5-Oct-09 23:57 
Hi All,

I need some help with customizing an upload.aspx. I have a VB.Net 2005
Winform that has a file picker and a textbox (plus loads of other stuff).
When the user selects a file, I want to upload the file to a server.

This is the command I am using in my Winform to upload the file:

My.Computer.Network.UploadFile(CStr(e.Value), Files_Dir, "user", "password",
True, 100, FileIO.UICancelOption.ThrowException)

Where Files_dir = http://server/upload.aspx

Separately, I've created an upload.aspx page that works fine. When I select
a file or type a filename into the textbox on the upload.aspx page and click
upload, the file is uploaded to the correct directory on the server.

The upload.aspx form is simple with just one textbox and 2 buttons:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transition al.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Upload</title>
</head>
<body>
<form id="frmUp" runat="server">
<div>
<input id="inpFile" type="file" runat="server" /><br/>
<asp:Button id="btn_Upload" runat="server" text="Upload" /><br
/>
<span id="txtMsg" runat="server" />
</div>
</form>
</body>
</html>

And the code behind:

Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles btn_Upload.Click
Dim i As Integer
Dim objFile As HttpPostedFile
Dim strFileName As String
Dim strMessage As String = ""

For i = 0 To Request.Files.Count - 1
objFile = Request.Files(i)
If Len(objFile.FileName) > 0 Then
strFileName objFile.FileName.Substring(objFile.FileName.LastInd exOf("\") + 1)
Try
objFile.SaveAs(Server.MapPath("~/Files") & "/" &
strFileName)
strMessage &= "<span>" & strFileName & " successfully
uploaded</span><br/>"
Catch ex As Exception
strMessage &= "<span>Failed uploading " & strFileName &
": " & ex.ToString() & "</span><br/>"
End Try
End If
Next i

txtMsg.InnerHtml = strMessage
End Sub

So, how do I pass the filename to be uploaded to the upload.aspx page?
(Something like http://server/upload.aspx?filename)??? I know the code
that's in the button click event will work when someone actually clicks the
button, but where do I put the code so that it'll fire when the winform
tries to upload a file? (It seems that the page load event might be ok, but,
is the page ever loaded?)

I don't want the Winform user to ever see the upload.aspx page. I just want
the Winform UploadFile command to use the form to put the file on the
server.

Any help would be greatly appreciated!!

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.