You need to sign in to do that
Don't have an account?
Variable does not exist: Name
Hello everyone,
I'm new in saleforce and Here i got a problem regarding "Variable does not exist: Name"
I just want to create a visual page and here code and controller class.
Please take a look
Visualpage code:
<apex:page standardController="Registration__c" extensions="Controller">
<apex:form >
<apex:pageBlock ><center><h1>Registration Form</h1></center></apex:pageBlock>
<apex:pageBlock title="Student Details" id="1">
<apex:pageBlockSection title="Jadu">
<apex:inputField value="{! Registration__c.Name }"/>
<apex:inputField value="{! Registration__c.Father_s_Name__c }"/>
<apex:inputField value="{! Registration__c.Mother_s_Name__c }"/>
<apex:inputField value="{! Registration__c.Phone__c }"/>
<apex:inputField value="{! Registration__c.Birth_Date__c}"/>
<apex:inputField value="{! Registration__c.Gender__c}"/>
<apex:inputField value="{! Registration__c.Email__c}"/>
<apex:inputField Value="{! Registration__c.Address__c}"/>
<apex:inputField value="{! Registration__c.Pincode__c}"/>
<apex:inputField value="{! Registration__c.City__c}"/>
<apex:inputField value="{! Registration__c.Country__c}"/>
<apex:inputField Value="{! Registration__c.State__c}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons location="bottom" >
<apex:commandButton action="{!save}" value="Save" />
<apex:commandButton action="{!show}" value="Show Registered Student " reRender="a" />
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlock title="Registrated Student" id="a">
{! Name} {! FatherName}
</apex:pageBlock>
</apex:form>
</apex:page>
Class code:
public with sharing class Controller {
public String Name;
public String FatherName;
public void show(){
List<Registration__c> Reg = new List<Registration__c>();
for(Registration__c obj :[select id, Father_s_Name__c,Name from Registration__c])
{
Reg.add(obj);
}
Name = Reg.Name;
FatherName = Reg.Father_s_Name__c;
}
}
Problem:
Variable does not exist: Name.
Variable does not exist: Father_s_Name__c.
1 in line 0 of Registration page
we should not give standard contoller just give controller.
orelse if you want standardController and extensions, Instead of giving 'Registration__c' , give a standard object.
Hi ,
Try something like this,
<apex:page Controller="ControllerCLS" sidebar="false">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputfield value="{!reg1.name}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public with sharing class ControllerCLS{
public Registration__c reg1{get;set;}
// add your code
}
for more reference:
https://www.salesforcetutorial.com/input-field-output-field-examples/
Hope it would help.
Have a nice day!.
Here the code;
Class code:
public with sharing class Controller {
Public Boolean Result{get;set;}
Public Registration__c[] Rec{get;set;}
public void Show(){
Rec = [select Name,id,Registration_No__c from Registration__c];
Result = false;
}
Public void ShowPB(){
Result= true;
}
}
Visualforce :
<apex:page controller="Controller">
<apex:form>
<apex:pageBlock >
<apex:commandButton value="Click me " action="{! ShowPB}"/>
</apex:pageBlock>
<apex:pageBlock rendered="{! Show}">
Name :<apex:outputField value="{!Rec[0].Name}"/>
<br/>
Registration :<apex:outputField value="{!Rec[0].Registration_No__c}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
Try below Controller.
public with sharing class Controller {
public String Name{get;set;}
public String FatherName{get;set;}
public void show(){
List<Registration__c> Reg = new List<Registration__c>();
for(Registration__c obj :[select id, Father_s_Name__c,Name from Registration__c])
{
Reg.add(obj);
}
Name = Reg.Name;
FatherName = Reg.Father_s_Name__c;
}
}
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Deepali Kulshrestha