1

I am getting the below error while saving the data. Please let me know where i am doing wrong -

apex:inputFile can not be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute.

public void UploadPhoto(){

            try{

                con.Name= conlastname;  
                con.First_Name__c= conemail;
                con.Family_Name__c= conphone;
                con.Gender__c= conmobilephone;
                con.Email__c = mail;
                insert con;


                Attachment a = this.tAttachment.clone(false, true, false, false);
                a.OwnerId = UserInfo.getUserId();
                a.ParentId = con.id;
                this.tAttachment.Body = null;
                insert a;

                message = ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'Record Created Successfully.Thank you!'));

            }catch(Exception e){
                system.debug('Exception message'+e);
            }
            return null;
    }

Vf Page -

<apex:page standardController="Devotee__c" sidebar="false" extensions="devoteeinsert" showHeader="false">    
    <style type="text/css">
       .img{width:100px !important;} 
       .bPageBlock .detailList tr td, .bPageBlock .detailList tr th, .hoverDetail .bPageBlock .detailList tr td, .hoverDetail .bPageBlock .detailList tr th { border-bottom: none !important;}
       .OptPanel{width:50%;float:left;padding-top:20px;borde:none !important; }   
       .Optpanel1{float:right;padding-right:100px;}   
       .bPageBlock, .individualPalette .bPageBlock
       {
            border: none !important;
           background:none !important;
       }

    </style>
    <apex:stylesheet value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" />
    <apex:includeScript value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"/>
    <apex:form >
        <apex:pageMessages id="showmsg"></apex:pageMessages>
         <fieldset>
            <legend>Devotee Registration</legend>
                <apex:outputpanel layout="block" styleclass="OptPanel">

                    </apex:pageblock>
               </apex:outputpanel>
                <apex:outputpanel layout="block" styleclass="Optpanel1">
                    <apex:pageblock mode="maindetail" >           
                        <apex:pageblocksection columns="1" >

                          <apex:inputFile value="{!tAttachment.Body}" filename="{!tAttachment.Name}" filesize="{!tAttachment.BodyLength}" contentType="{!tAttachment.ContentType}" />
                              <apex:commandButton value="Save Data" action="{!uploadphoto}" rerender="showmsg" />                                    
                        </apex:pageblocksection>

                    </apex:pageblock>
                 </apex:outputpanel>
           </fieldset>
    </apex:form>
</apex:page>
1

You need to remove rerender from your commandbutton tag. It will solve your problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.