Adding File Upload Functionality to the Jobs Module Sample from the Sitefinity SDK

April 26, 2013 Digital Experience

This blog post provides a sample which extends the Jobs module sample in the Sitefinity SDK so as to allow upload of files to the job application and to display a link to the uploaded files in the list of submitted applications.

Here is the sample code with the below implementations.

  1. Add file upload control to the frontend widget that submits job applications JobApplicationUpload.ascx and perform the upload of the document:
<telerik:RadUpload ID="RadUpload1" runat="server" AllowedFileExtensions=".doc,.docx,.pdf,.txt,.rtf,.odt" MaxFileInputsCount="1" Width="100%" InputSize="45" ControlObjectsVisibility="None"/>
<br />
<asp:TextBox ID="CV" runat="server" Width="100%" MaxLength="40" />

Add the logic for document uploading in  JobApplicationUpload.cs  in UploadApplication method. I have put comments in the method and hope you will be able to make use of them.

   2.Add additional column in jobs module uploaded items grid to render a link to the uploaded file

The tricky part is to render the link to the uploaded document in the grid among the other fields. The UploadApplicaiton method returns the link to the document (its a full link that allows you to download or display a document in the browser depending on the document extension ".doc, .pdf").
To render the link as <a> tag in the client template of the grid column use this in JobsDefinitions.cs

Add new DataColumnElement to display the uploaded file link. I have associated the uploaded file with the column LastName and the client template for LastName will display <a> like below:

DataColumnElement lastNameColumn = new DataColumnElement(gridMode.ColumnsConfig)
            {
                Name = "LastName",
                HeaderText = Res.Get<JobsResources>().LastName,
                ClientTemplate = "<a sys:href=\"{{LastName}}\">{{LastName}}</a>",
                HeaderCssClass = "sfRegular",
                ItemCssClass = "sfRegular"
            };
gridMode.ColumnsConfig.Add(lastNameColumn);

 

And finally, the place to map the uploaded file to one of the Grid columns is:

private void JobApplicationUpload_Click(object sender, EventArgs e)
        {
            //the ID of the Job
            var jobApplicationID = Guid.NewGuid();
            var manager = new JobsManager();
            var application = manager.CreateJobApplication(jobApplicationID);
 
            application.FirstName = this.FirstName;
//addition of the uploaded file
            application.LastName = UploadApplication(this.RadUpload1.UploadedFiles[0]);
           

 

The Progress Team