Click here to Skip to main content
16,015,393 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good morging!
I have two link at page: edit and add and one button Submit.
When i click it edit, mu button changes text on "Edit", and changes to "Add" when click another link
I want no make that my button function two actions: edit and add. What i must to send button, that after in body of button_click() catch it and meke tru condition?

So i can check it how as:
C#
button_click () {
if (BtnAct.text == "Add") {
this.Add();
} else {
this.Edit();
}

}

But it is ugly code
Posted
Comments
gouravkaila 19-Mar-13 6:49am    
lolz!

I think checking the text property is really a bad idea.

On what condition you are changing the text??? You may use the same condition to alter a sever side flag let say a boolean type isAddButton. Make it true/false and use it rather than using client side control properties.

:):)
 
Share this answer
 
make one Enum variable like
public Enum Action
{
    Add, Edit
};

make one public property of it like
public Action EnumAction
{
    get;
    set;
}

now when u want to make action "add" then simply assing the value of EnumAction = Action.Add
and when u want to make action "edit" then simply assing the value of EnumAction = Action.Edit

and check it at your button click event...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900