Even though I have it working its not working the way I want.
The idea is to have some text directly call one of my ServerSided ASP.NET functions.
Basically I am trying to delete photos
This is the code in my Page_Load function
//delete photo
if(Page.IsPostBack){
if(Request.Form["__EVENTARGUMENT"]!=""){
deletephoto(Request.Form["__EVENTARGUMENT"]);
}
} |
This is the code in my function that deletes the photo
void deletephoto(string id){
// get photo
Response.Write("function called for "+id);
string photo=countDB3("SELECT filename FROM blogs_photos WHERE id='"+id+"'");
if(photo!=""){
//delete photo
string filepath="blogs/large/"+photo;
File.Delete(Server.MapPath(filepath));
filepath="blogs/medium/"+photo;
File.Delete(Server.MapPath(filepath));
filepath="blogs/small/"+photo;
File.Delete(Server.MapPath(filepath));
filepath="blogs/thumb/"+photo;
File.Delete(Server.MapPath(filepath));
}
insertToDB("DELETE FROM blogs_photos WHERE id='"+id+"'");
} |
Here is a javascript function from the client side
function deletepic(picid)
{
__doPostBack('deletephoto',picid);
} |
and here is the text link
| <a href="javascript:deletepic('id_of_photo');">DELETE</a> |
What I want to do is directly call my deletephoto ASP.NET function without the check in my Page_Load to see if its a PostBack. Is there anyway to do this?