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
S Dhanasekaran
Posts
-
Winform UploadFile to Upload.aspx page (VB.Net 2005) -
Need help [modified]hi.. I need your ftp details. once i check in server, then only i tell
-
Alignment proble in firefoxHi... In IE browser take a width in pixels as default. But in Mozilla u must set in Percentage(%) only. Ex: style="width:30%"
-
DataTableColumn.AutoIncrementSeed valueHi, To add auto increment column in the DataTable, we can set the AutoIncrement property of the DataColumn object as true and specify the seed value after adding that field into the DataTable object. // create columns for the DataTable DataTable dTable = new DataTable(); DataColumn auto = new DataColumn("AutoID", typeof(System.Int32)); dTable.Columns.Add(auto); // specify it as auto increment field auto.AutoIncrement = true; auto.AutoIncrementSeed = 1; auto.ReadOnly = true;
-
How to get value from dynamic radio buttonHi, can u explain briefly? which datacontrol used to bind the value?
-
Hi, I need help !!!Hi, do changes in frist column(Viewdetails) <asp:HyperLink ID="hypTitle" NavigateUrl='<%#"secondpage.aspx?pid="+DataBinder.Eval(Container.DataItem,"picid")%>' Text='<%#DataBinder.Eval(Container.DataItem,"picturename") %>' runat="server" ></asp:HyperLink> when click the viewdetails column, i pass Querystring("pid") value of current picture. On second page, get value from querystring("pid"), using to display the picture.
-
Problem in Default.aspxHi, Delete all files inside bin folder in live site and upload again.
-
LINQ DisadvantagesAnyhow, you are somewhat comparing apples and oranges. LINQ to XML (and LINQ in general) is a query language whereas XSLT is a programming language to transform XML tree structures. These are different concepts. You would use a query language whenever you want to extract a certain specific piece of information from a data source to do whatever you need to do with it (be it to set fields in a C# object). A transformation, in contrast, would be useful to convert one XML representation of your data into another XML representation. So if your aim is to create C# objects from XML, you probably don't want to use XSLT but any of the other technologies offered by the .NET Framework to process XML data: the old XmlDocument, XmlReader, XPathDocument, XmlSerializer or XDocument. Each has it's special advantages and disadvantages, depending on input size, input complexity, desired output etc.
-
Content-Disposition attachment not working in IE 7Try this ============ byte[] message; // converting a tiff image file into byte[] bool ret = false; string filepath = "C:\"; if (Contentdisposition != null) { ret = Contentdisposition.StartsWith(" attachment;"); //code to decode the data if (ret && (contentTransferEncoding.ToUpper().Equals("BASE64"))) { //create the file and store the binart data //store to test create the file with attachment name later string[] filename = Contentdisposition.Split(';'); attachfile = filename[1]; attachfile = Regex.Replace(attachfile, "^[ | ]+filename=[\"]*([^\"]*).*$", "$1"); filepath+=attachfile; m_binaryData = Convert.FromBase64String(message.Replace("\n", "")); System.IO.BinaryWriter bw = new BinaryWriter(new FileStream(filepath, System.IO.FileMode.Create)); bw.Write(m_binaryData); bw.Flush(); bw.Close(); } }
-
LINQ DisadvantagesDisadvantages of LINQ over Stored Procedures ----------------------------------------------- 1) Network traffic: sprocs need only serialize sproc-name and argument data over the wire while LINQ sends the entire query. This can get really bad if the queries are very complex. However, LINQ's abstraction allows Microsoft to improve this over time. 2) Less flexible: Sprocs can take full advantage of a database's featureset. LINQ tends to be more generic in it's support. This is common in any kind of language abstraction (e.g. C# vs assembler). 3) Recompiling: If you need to make changes to the way you do data access, you need to recompile, version, and redeploy your assembly. Sprocs can sometimes allow a DBA to tune the data access routine without a need to redeploy anything.
-
gridview date sorting in asp.net?????????????????hi, Here i add a sample code for sorting 1) In Gridview Properties add this AllowSorting="true" OnSorting="gridView1_OnSorting" 2) In gridView use TemplateField Column <asp:TemplateField HeaderText="joiningdate" HeaderStyle-HorizontalAlign="Left" SortExpression="joiningdate" ItemStyle-Width="30%"> <ItemTemplate > <span id="joiningdate" runat="server" style="color:Black;" ><%#Eval("joiningdate") %></span> </ItemTemplate> </asp:TemplateField> 3) create a Event gridView1_Onsorting protected void gridView1_OnSorting(object sender, GridViewSortEventArgs e) { string sortExpression = e.SortExpression; ViewState["sortExpression"] = e.SortExpression; if (GridViewSortDirection == SortDirection.Ascending) { GridViewSortDirection = SortDirection.Descending; SortGridView(sortExpression, "DESC"); } else { GridViewSortDirection = SortDirection.Ascending; SortGridView(sortExpression, "ASC"); } } 4) Create a SortGridView() Method private void SortGridView(string sortExpression, string direction) { DataTable dt = null; dt = "test" // fill the Datatable rows using sqlcommand or Dataset DataView dv = new DataView(dt); dv.Sort = sortExpression + " " + direction; gridView1.DataSource = dv; gridView1.DataBind(); } 5) Create a enum SortDirection public SortDirection GridViewSortDirection { get { if (ViewState["sortDirection"] == null) ViewState["sortDirection"] = SortDirection.Ascending; return (SortDirection)ViewState["sortDirection"]; } set { ViewState["sortDirection"] = value; } }
-
Resource file in .netTry below link Creating multilingual websites[^] Creating multilingual application[^]
-
add controls inside datagridview windows controlHi all I am using vs2005 and windows form I want add a control inside the datagridview's (windows control ) cell I dont find any method similar to gridview webcontrol's gridview.rows[0].cells[0].controls.add() anyone can post the code snippet for this thanx a lot
-
How do I read the received emails using ASP .NET?We can send mail using System.Net.Mail namespace in ASP .NET. But do we have any API to read mails via POP server using ASP .NET? Please help as I have not come across any such thing. Will I be able to read every details of the mail i.e. all the headers and the body?
-
string tokenizebool chkspchar = Regex.IsMatch(txtBrandName.Text, "[^A-Za-z0-9-]+"); if(!chkspchar) { strBrandName = Regex.Replace(txtBrandName.Text, "[^A-Za-z0-9-]+", "").Trim().ToLower(); }
-
Problem with gridviewMap Primarykey values into Gridview Datakeynames Property. ex: DataKeyNames="" int id = (int)gridview1.DataKeys[e.RowIndex].Value;
-
How to dispaly columndata horizontal in gridview....instead of using gridview use datalist
-
How to get the Gridview data into DataTable [modified]Try this DataTable workTable= new DataTable(); DataRow workRow = workTable.NewRow(); foreach(DataRow workRow in Gridview1.Rows) { workRow["Fields"] = //your gridview rows dt.Rows.Add(workRow); }
-
category tree like structurei am building a category tree like structure for my FAQ app. i need to show all active categories. The hitch is that if a parent category is checked as inactive, then the sub or child categories under it should not be displayed even if they are marked as active. I need a query which will return me such a resultset which i can display in a table. the columns in my table are categoryid, category, ParentcategoryID,companyID and active. The ParentcategoryID contains id of another category or 'No parentcategory' which denotes its the main category. It is easy to get the immediate parentcategory and find out if its active or not. But to find out if that parent category's parent and so on is active or not is tough. please help.
-
category tree like structure in sqlHi all, i am building a category tree like structure for my FAQ app. i need to show all active categories. The hitch is that if a parent category is checked as inactive, then the sub or child categories under it should not be displayed even if they are marked as active. I need a query which will return me such a resultset which i can display in a table. the columns in my table are categoryid, category, ParentcategoryID,companyID and active. The ParentcategoryID contains id of another category or 'No parentcategory' which denotes its the main category. It is easy to get the immediate parentcategory and find out if its active or not. But to find out if that parent category's parent and so on is active or not is tough. please help.