[CLOSED] File download In MVC

  1. #1

    [CLOSED] File download In MVC

    Hi
    I am trying to add file download functionality in my application,for that I do bellow code.Its check in Index() function there are download link available or not?If yes then its visible.

    X.LinkButton().Text("Download").ID("UploadPath_1")
    public ActionResult Index()
            {
     if (string.IsNullOrWhiteSpace("Some Path") == true)//Check data base field contains path or not.
                    {
                        X.GetCmp<LinkButton>("UploadPath_1").Hide();
    
                    }
                    else
                    {
                        //string url = "downloadFile?path=VendorQuotation_Document_1_UploadPath &" + obj_tbl_Pur_Trans_Quotation_Master.QuotationID + "";
                        X.GetCmp<LinkButton>("UploadPath_1").Show();
                        X.GetCmp<LinkButton>("UploadPath_1").DirectEvents.Click.Action = "downloadFile";
                        X.GetCmp<LinkButton>("UploadPath_1").DirectEvents.Click.FormID = "f";
                        X.GetCmp<LinkButton>("UploadPath_1").DirectEvents.Click.IsUpload = true;
                        X.GetCmp<LinkButton>("UploadPath_1").DirectEvents.Click.ExtraParams.Add(new Parameter { Name = "path", Value = "VendorQuotation_Document_1_UploadPath" });
                        X.GetCmp<LinkButton>("UploadPath_1").DirectEvents.Click.ExtraParams.Add(new Parameter { Name = "id", Value = obj_tbl_Pur_Trans_Quotation_Master.QuotationID.ToString(), Mode = ParameterMode.Raw });
                    }
                    return View();
    }
    
    public void downloadFile(string path, string id)
            {
    
            }
    after page load downloadFile function not called.
    Last edited by Daniil; Nov 18, 2014 at 5:26 PM. Reason: [CLOSED]
  2. #2
    Hi @matrixwebtech,

    Changing a control's DirectEvents on the fly doesn't affect on client. A DirectEvents option is not supposed to be changed on the fly.

    Maybe, you can define a static DirectEvent?
    Last edited by Daniil; Nov 18, 2014 at 5:25 PM.
  3. #3
    hi
    daniil,
    the problem is the file id is dynamic
    X.GetCmp<LinkButton>("UploadPath_1").DirectEvents.Click.ExtraParams.Add(new Parameter { Name = "id", Value = obj_tbl_Pur_Trans_Quotation_Master.QuotationID.ToString(), Mode = ParameterMode.Raw });
    so is there any way to do this?
  4. #4
    Hi

    X.GetCmp can be used in conjunction with DirectResult only (it cannot be used with ViewResult) because it generates script for already rendered widgets
    If you want to configure some widgets before render in a view then pass required data to the view and set required properties inside view
    Last edited by Vladimir; Nov 13, 2014 at 2:25 PM.

Similar Threads

  1. Replies: 4
    Last Post: Oct 25, 2014, 1:12 AM
  2. Unable to Download Ext.net.example.dll file
    By Binai in forum 2.x Help
    Replies: 4
    Last Post: Jul 23, 2014, 2:22 PM
  3. 2.1 zip file download
    By gdog_5021 in forum 2.x Help
    Replies: 4
    Last Post: Dec 03, 2012, 11:14 AM
  4. [CLOSED] Download a file in an MVC app
    By Stefanaccio in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jul 02, 2010, 9:01 PM
  5. File download
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Dec 05, 2008, 7:22 AM

Posting Permissions