function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
maheshkovvadamaheshkovvada 

Visualforce Registration

How to create 'Registration ' page in visualforce..Like username and password

how to create password text box for  Registration.

Suresh RaghuramSuresh Raghuram

<apex:page StandardController="Contact" extensions="UserCtrl" action="{!autorun}" >
<apex:pageMessages ></apex:pageMessages>
<apex:sectionHeader title="Create User" help="/help/doc/user_ed.jsp?loc=help"/>
<apex:form >
<apex:PageBlock title="Create User">
<apex:pageBlockButtons >
<apex:commandButton value="submit" action="{!submit}" rerender="existingContacts"/>
<apex:commandButton value="Home" action="{!Home}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="2" >
<apex:pageBlockSectionItem >User Name<apex:inputText value="{!xName}"/></apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >Password<apex:inputSecret value="{!xPassword}"/></apex:pageBlockSectionItem>
<apex:pageBlockSectionItem > <apex:outputLabel value="Security Question" />
<apex:selectList size="1" value="{!SelectedValue}">
<apex:selectOptions value="{!statusOptions}"/></apex:selectList></apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >Answer<apex:inputText value="{!xAnswer}"/></apex:pageBlockSectionItem>
</apex:pageBlockSection>

</apex:PageBlock>
</apex:form>
</apex:page>

maheshkovvadamaheshkovvada

k Thank You.The below error is coming how to solve pls rly me...

Error: action="{!autorun}": Unknown method 'ContactStandardController.autorun()

Suresh RaghuramSuresh Raghuram

dont do as it is you asked for the username and password fields so igave this code since i was busy i copy pasted all the code in this autorun code is used soem other purpose like picklist

i will also give you the class code just for your better understanding there were soem errors in that since i made some changes for my requirement

public with sharing class UserCtrl {
public ApexPAges.StandardController stdController { get;set; }
public List<MyContact__c> eContacts { get;set; }
public UserCtrl(ApexPages.StandardController controller) {
//stdController = (Contact) controller;
// existingContacts = false;
// editMode = false;
eContacts = new List<MyContact__c>();
}
public String statusOption1 { get; set; }
public String SelectedValue1 { get; set; }
public String MyContact { get; set; }
public string selectedValue { get;set; }
public List<SelectOption> statusOptions { get;set; }
public boolean editMode { get;set; }
public String selectedID { get;set; }
// public boolean existingContacts {get;set; }


public void saveContact(){
system.debug('Selected ID================>>>>'+selectedID);
editMode = false;
MyContact__c selectedContact = [Select User_Name__c, Password__c From MyContact__c Where Id=:selectedID];
selectedContact.User_Name__c = xName;
selectedContact.Password__c = xPassword;
system.debug('Selected Contact================>>>>'+selectedContact);
try{
update selectedContact;
}catch(Exception e){

}
}

public void deleteContact(){

}
public void autoRun()
{
// Schema.DescribeFieldResult statusFieldDescription = Account.Rating.getDescribe();
Schema.DescribeFieldResult statusFieldDescription = MyContact__c.Security_Question__c.getDescribe();
statusOptions = new list<SelectOption>();

for (Schema.Picklistentry picklistEntry : statusFieldDescription.getPicklistValues())
{
statusOptions.add(new SelectOption(pickListEntry.getValue(),pickListEntry.getLabel()));
}
}

public String xName { get; set; }
public String xAnswer { get; set; }
public String xPassword { get; set; }
public String getXUserName() {
return null;
}
public PageReference Home() {

PageReference pf=new PageReference('/apex/page4');
return pf;
}

public pageReference Submit() {
MyContact__c Mc = new MyContact__c();
eContacts = [select User_Name__c, Password__C from MyContact__c where User_Name__c =: xName and Password__c =: xPassword];
//savepoint sp = database.setSavePoint();
system.debug('*****+LIST+**********' +eContacts );
Mc.User_Name__c = xName;
Mc.Password__C = xPassword;
Mc.Security_Question__c = SelectedValue;
Mc.Answer__c = xAnswer;

if(eContacts.Size() >0){
//existingContacts = true;
//return;

pageReference pr= new pageReference('/apex/DuplicateUsers');
//pr.setRedirect(false);
system.debug('Pagereference>>>>>>>>' +pr);

return pr;

}else{
// existingContacts = false;
try{
insert Mc;
}catch(Exception e){
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'anna enter valid User Name and Password '+e.getMessage()));
}
return null;
}

}

}

maheshkovvadamaheshkovvada

Thank You sir...still this error is coming:

Error: action="{!autorun}": Unknown method 'ContactStandardController.autorun()

Suresh RaghuramSuresh Raghuram

take off the autorun from the <apex:Page> tag where ever it is it is not necessary for your requirement. 

 

Just take the username password only those are relevant to your question remaining out of your requirement