Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > File upload properties in viewBiz_OnBeforeSave method? View modes: 
User avatar
Member
Member
Dlglsh - 7/26/2012 5:28:32 AM
   
File upload properties in viewBiz_OnBeforeSave method?
Hi all,

Can anyone please tell me if it is possible to access the properties of a file upload field in the viewBiz_OnBeforeSave() method?

If I use this.viewBiz.BasicForm.GetFieldValue("Fieldname").ToString() it's just an empty string.

I need to use it in the viewBiz_OnBeforeSave() method because depending on another variable it checks to see if a file has been selected. If not, then StopProcessing and display error message.

Thanks,

Matt

User avatar
Member
Member
Dlglsh - 7/26/2012 5:42:06 AM
   
RE:File upload properties in viewBiz_OnBeforeSave method?
I think I've solved it. I'll post how I did it shortly in case anyone else comes across the same problem.

User avatar
Member
Member
Dlglsh - 7/26/2012 6:32:25 AM
   
RE:File upload properties in viewBiz_OnBeforeSave method?
Ok, so I didn't access the upload file properties in the viewBiz_OnBeforeSave() method directly, instead I created a property, UploadFileName.

I used this as a guide: clicky.

So, I added viewBiz.OnUploadFile += new EventHandler(viewBiz_OnUploadFile); to the SetupControl() method.

Then I created this:


void viewBiz_OnUploadFile(object sender, EventArgs e)
{
CMS.ExtendedControls.Uploader ctrlUploader = (CMS.ExtendedControls.Uploader)sender;
if (ctrlUploader != null)
{
_uploadFileName = ctrlUploader.PostedFile.FileName;
}
}


Lastly, in my viewBiz_OnBeforeSave() method, I validated the value of _uploadFileName.

I hope that helps anyone.

Matt