• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 294
  • Last Modified:

ASP.net Ajax If else Statement

Hi All,

I have a function below which doesnt seem to be working as you would expect it to, it always hits the first switch which is 'btnedit' can anyone see something wrong?

   function menuFeatureProperties(s, e) {
        var sname = e.item.name;
        alert(sname);
        if (sname = 'btnEdit'){
            alert(sname);
            var index = grid_ftrProperties.GetFocusedRowIndex();
            grid_ftrProperties.StartEditRow(index);
        }
        else
        if (sname = 'btnNew'){
            alert(sname);
            grid_ftrProperties.AddNewRow();
        }
        else
        if (sname = 'btnDelete'){
                alert(sname);
            var index = grid_ftrProperties.GetFocusedRowIndex();
            grid_ftrProperties.DeleteRow(index);
            }
        }
0
Zeus2009
Asked:
Zeus2009
2 Solutions
 
Alfred A.Commented:
This is a bit of a longshot but can you try replacing e.item.name; with e.item().Name;?  
0
 
Carl TawnSystems and Integration DeveloperCommented:
Yep, simple syntax error. Your = (assign to) should be == (compare to)
0
 
leakim971PluritechnicianCommented:
Like this : if (sname == 'btnEdit'){

and not : if (sname = 'btnEdit'){
0
 
Alfred A.Commented:
Oh yeah.  Agree with @carl_tawn.  That should be the problem.  Common syntax error that even I myself has domestic blindness to it from time to time.  :-)
0
 
Zeus2009Author Commented:
Clean precise and worked, i have been looking at this damn code for 2 days and couldnt figure out what was happening.

Thanks Guys/Gals
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now