my current code (that doesn't do anything):
if (Request.Form["delete"] != null)
and the delete button is generated in the C# behind the page:
public string delete = ""; //in the public partial class
delete += " <button name=\"delete\"/>Delete</button>";
once I click the button - nothing happens, how can I change the if
(or the delete
which is the button) so that after I press the button the code will execute?
for example:
when I press the button, a message will appear...
if (Request.Form["delete"] != null)
{
Response.Write("inside the if");
}
side note:
I've tried using this code
Button clickedButton = sender as Button;
if (clickedButton.ID == "delete")
and it didn't work as well.
if (Request.Form["delete"] != null)
{
and put your button in a form
.
the form
:
<form name="form_name" action="your_page.aspx" method="post" >
<input type="submit" name="delete" value="delete"/>
</form>
the problem? my button wasn't a submit
button. you HAVE to use type=submit
on it so that after it's clicked, it will actually "go to" the form
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.