Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Trang 1 của 2 12 CuốiCuối
Kết quả 1 đến 10 của 11
  1. #1
    Ngày tham gia
    Sep 2015
    Bài viết
    0

    Sử dụng OpenFileDialog và SaveFileDialog trong Asp.net giống như trong WindowsForms(C#) như thế nào?

    mọi người giúp mình về code của OpenFileDialog và SaveFileDialog trong asp.net với !
    khi click vào Button mình muốn sẽ mở ra box OpenFileDialog hoặc SaveFileDialog.
    mình có làm khi chạy ko có lỗi gì chỉ khi click vào button mới xảy ra lỗi.
    Mã:
    protected void TimFile(object sender, EventArgs e)
        {
            OpenFileDialog ofdbk1 = new OpenFileDialog();
            ofdbk1.Title = "Tìm File CSDL cần Sao Lưu";
            ofdbk1.Filter = "File (*.mdf)|*.mdf|All File (*.*)|*.*";
            if (ofdbk1.ShowDialog() == DialogResult.OK)// thường là báo lỗi ở đây
            {
                tb1_bk.Text = ofdbk1.FileName;
            }
        }
    mong mọi người giúp đõ,
    cảm ơn rất nhiều !

  2. #2
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trong asp.net không có cái đó bạn à chỉ có control FileUpload thôi:

    Mã:
    http://asp.net-tutorials.com/controls/file-upload-control/

  3. #3
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Trích dẫn Gửi bởi haiht
    Trong asp.net không có cái đó bạn à chỉ có control FileUpload thôi:

    [CODE]http://asp.net-tutorials.com/controls/file-upload-control/
    ko con cách khác nữa ah bạn?

  4. #4
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Mình xây dựng chức năng Sao lưu và phục hồi dữ liệu dưới dạng website cho 1 ứng dụng website quản lý điểm .cài đặt trên máy chủ và chạy trong mạng LAN.
    công cụ là Visual C# 2008 và Sql server 2005.
    ai thông hiểu về code giúp mình cái sự kiện Onclick vào Button mở ra hộp thoại giống như thế này

    [IMG]http:/k1.upanh.com/b5.s13.d3/699782636f93b68321f58794c36cbe6b_43299681.button.p ng[/IMG]
    rất cảm ơn

  5. #5
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    xài control FileUpload thì nó cũng có khác gì

  6. #6
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    ko có open và save dialog đâu các bác, xài fileupload đi

  7. #7
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    ko còn cách khác sao mọi người?

  8. #8
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    mọi người ai biết code html hoặ javascript mà làm được như vậy ko?chỉ mình với

  9. #9
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    mình làm bằng flash và jquery.
    ảnh demo.








    yêu cầu cần:
    file flash: FlashFileUpload.swf
    file cs quản ký phần ghi ảnh: MultiFlashUpload.cs
    file js:jquery.MultiFile.js,AC_RunActiveContent.js
    code:
    Mã:
    // According to http://msdn2.microsoft.com/en-us/library/system.web.httppostedfile.aspx
    // "Files are uploaded in MIME multipart/form-data format. 
    // By default, all requests, including form fields and uploaded files, 
    // larger than 256 KB are buffered to disk, rather than held in server memory."
    // So we can use an HttpHandler to handle uploaded files and not have to worry
    // about the server recycling the request do to low memory. 
    // don't forget to increase the MaxRequestLength in the web.config.
    // If you server is still giving errors, then something else is wrong.
    // I've uploaded a 1.3 gig file without any problems. One thing to note, 
    // when the SaveAs function is called, it takes time for the server to 
    // save the file. The larger the file, the longer it takes.
    // So if a progress bar is used in the upload, it may read 100%, but the upload won't
    // be complete until the file is saved.  So it may look like it is stalled, but it
    // is not.
    
    using System.IO;
    using System.Net;
    using System.Web;
    using albumanh;
    
    namespace ASP.NET.VN
    {
        public class MultiFlashUpload : IHttpHandler
        {
            #region IHttpHandler Members
    
            public bool IsReusable
            {
                get { return true; }
            }
    
            public void ProcessRequest(HttpContext context)
            {
                manager mn=new manager();
                // Example of using a passed in value in the query string to set a categoryId
                // Now you can do anything you need to witht the file.
                //int categoryId = 0;
                //if (context.Request.QueryString["CategoryID"] != null)
                //{
                //    try
                //    {
                //        categoryId = Convert.ToInt32(context.Request.QueryString["CategoryID"]);
                //    }
                //    catch (Exception err)
                //    {
                //        categoryId = 0;
                //    }
                //}
                //if (categoryId > 0)
                //{
                //}
    
                if (context.Request.Files.Count > 0)
                {
                    // get the applications path
                    string tempFile = context.Request.PhysicalApplicationPath;
                    // loop through all the uploaded files
                    for (int j = 0; j < context.Request.Files.Count; j++)
                    {
                        // get the current file
                        HttpPostedFile uploadFile = context.Request.Files[j];
                        // if there was a file uploded
                        if (uploadFile.ContentLength > 0)
                        {
                            // save the file to the upload directory
    
                            //use this if testing from a classic style upload, ie. 
    
                            // <form action="Upload.axd" method="post" enctype="multipart/form-data">
                            //    <input type="file" name="fileUpload" />
                            //    <input type="submit" value="Upload" />
                            //</form>
    
                            // this is because flash sends just the filename, where the above 
                            //will send the file path, ie. c:\My Pictures\test1.jpg
                            //you can use Test.thm to test this page.
                            //string filename = uploadFile.FileName.Substring(uploadFile.FileName.LastIndexOf("\\"));
                            //uploadFile.SaveAs(string.Format("{0}{1}{2}", tempFile, "Upload\\", filename));
    
                            // use this if using flash to upload
                            string name = mn.ghiAnh(uploadFile.FileName);
                            uploadFile.SaveAs(string.Format("{0}{1}{2}", tempFile, "Uploads\\", name));
    
    
                            // HttpPostedFile has an InputStream also.  You can pass this to 
                            // a function, or business logic. You can save it a database:
    
                            //byte[] fileData = new byte[uploadFile.ContentLength];
                            //uploadFile.InputStream.Write(fileData, 0, fileData.Length);
                            // save byte array into database.
    
                            // something I do is extract files from a zip file by passing
                            // the inputStream to a function that uses SharpZipLib found here:
                            // http://www.icsharpcode.net/OpenSource/SharpZipLib/
                            // and then save the files to disk.                    
                        }
                    }
                }
                mn.setAnhNen();
                mn.capnhatalbum(idalbum.id.ToString());
                // Used as a fix for a bug in mac flash player that makes the 
                // onComplete event not fire
                HttpContext.Current.Response.Write("Thanh Cong! ");
                
    
            }
    
            #endregion
        }
    }
    thêm flash ở file aspx
    Mã:
    ...
        <script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
        <script type="text/javascript" src="Scripts/jquery.MultiFile.js"></script>
        <script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
    ...
    <asp:Panel ID="Panel1" runat="server" Visible="False">
                    <script type="text/javascript">
    AC_FL_RunContent( 'id','fileUpload','align','middle','codebase','http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0','height','375','width','575','allowscriptaccess','sameDomain','flashvars','uploadPage=MultiFlashUpload.axd<%=GetFlashVars()%>&completeFunction=UploadComplete()','name','fileUpload','pluginspage','http://www.macromedia.com/go/getflashplayer','quality','high','src','FlashFileUpload','wmode','transparent','movie','FlashFileUpload' ); //end AC code
    </script><noscript><object id="fileUpload" align="middle" 
                                    classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" 
                                    codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" 
                                    height="375" width="575">
                                    <param name="allowScriptAccess" value="sameDomain" />
                                    <param name="movie" value="FlashFileUpload.swf" />
                                    <param name="quality" value="high" />
                                    <param name="wmode" value="transparent" />
                                    <param name="FlashVars" 
                                        value="uploadPage=MultiFlashUpload.axd<%=GetFlashVars()%>&completeFunction=UploadComplete()" />
                                    <embed align="middle" allowscriptaccess="sameDomain" 
                                        flashvars="uploadPage=MultiFlashUpload.axd<%=GetFlashVars()%>&completeFunction=UploadComplete()" 
                                        height="375" name="fileUpload" 
                                        pluginspage="http://www.macromedia.com/go/getflashplayer" quality="high" 
                                        src="FlashFileUpload.swf" type="application/x-shockwave-flash" width="575" 
                                        wmode="transparent"></embed>
            </object><oscript>
                                
                                <asp:LinkButton ID="LinkButton1" runat="server" CssClass="dongupload" 
                                        onclick="LinkButton1_Click">Đóng Upload</asp:LinkButton>
                                </asp:Panel>
    mình làm trên xml lên các bạn dowload code về tham khảo nhé.thắc mắc post lên đây.cái này là cái assignment môn begin asp.net của mình.còn mấy chức năng quản lý xóa,di chuyển ảnh chửa làm xong.
    có thể tham khảo thêm flash ở đây: http://www.codeproject.com/Articles/...ar-Using-Flash
    http://boyprodx.blogspot.com/2009/05...flash-swf.html

  10. #10
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Thanks ducnv_b01048

 

 
Trang 1 của 2 12 CuốiCuối

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •