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
rupesh ranjanrupesh ranjan 

Error : expecting right curly bracket, found 'if'

expecting right curly bracket, found 'if'
 
<select id="MySelectMenu">
<option value="f">Demos On Demand Report</option>
<option value="s">Pointmarketing Report</option>
</select>
 
public   String MySelectMenu { get; set; }
    public   String SelectMenu { get; set; }
    if(MySelectMenu == 'Demos On Demand Report' ){
    SelectMenu = 'DemosOnDemandReport';
    }
    else(MySelectMenu == 'Pointmarketing Report' ){
    SelectMenu = 'PointmarketingReport';
      }




 
mayurmayur
Please send me your full code on kauravmayur@gmail.com
sandeep sankhlasandeep sankhla
Hi,

You cant keep if else directly inside class, these should be inside some method or constructor. so you can add these in constructor or create a method where you will be adding these and then call that method from constructor.

Thanks!
Head In CloudHead In Cloud
Hi rupesh,
I found Some error in your code please review the suggetion given below
  • Define the if statement in the method of the Class or in constructor
Example :-
public unit1() {
if(MySelectMenu == 'Demos On Demand Report' ){
SelectMenu = 'DemosOnDemandReport';
}
else(MySelectMenu == 'Pointmarketing Report' ){ SelectMenu = 'PointmarketingReport';
}
}
  • If else problem, you have to use nested if in your condition.
Example :-
if(MySelectMenu == 'Demos On Demand Report' ){
SelectMenu = 'DemosOnDemandReport';
}
else if(MySelectMenu == 'Pointmarketing Report' ){
SelectMenu = 'PointmarketingReport';
}
else{
}

Hope this helps you!
Thanks
Manish Sharma 182Manish Sharma 182
public class dobapespage {
   public string name ='manish';
    public decimal marks =55;
    public boolean result =true;

     if(name == 'manish' ){
    marks = '35';
result = 'true';
     } else{  
         marks = 25;
         result = false;
    
    }