If you want to do all this in server-side code, one way to do it is use multiple submit buttons, and give your submit buttons the same name in the HTML but different values, then inspect for the value in the server side code when IsPost is true.
Here's an example of a couple of submit elements with same name, but different values. These could be up and down buttons:
1 2 3
| <input type="submit" name="imgBtnGroup" value="up" />
<input type="submit" name="imgBtnGroup" value="down" /> |
On the server, you could use code like this to assign the posted value from the request object:
string buttonAction = Request["imgBtnGroup"];
Then you could use a case statement, or a series of if statements, to test the value of buttonAction and respond accordingly.
1 2 3 4 5 6 7 8 9 10 11
| if(buttonAction == "up") {
// Do something
}
else if (buttonAction == "down") {
// and so on
} |
Finally, you might want to use CSS to style the submit buttons and make them look nicer. You can even use CSS to supply background-image attributes to input elements, so that you can use an image instead of just a plain button. Use your Bing or Google-Fu to search for CSS solutions to add images to HTML form elements, there are lots of examples out there.
Partager