Question: I want to delete a `directory` when its clicked on a `hyperlink`.I tried like the below.But my page redirecting to `default(start) page` and the `directory` is not deleting.

```
protected void Page_Load(object sender, EventArgs e)
{
    Execute(s,Content,k,j);
}

private void Execute(string path,string cont,string sym,string space )
{
    foreach (var directory in new DirectoryInfo(path).GetDirectories())
    {
        string f = directory.FullName;  
        f = Server.UrlPathEncode(f);

        Response.Write("<a href =''" + "onclick='Delete(" + f + ")'> DELETE </a>");

        Execute(directory.FullName,cont1,sym1,space1);
    }
}

private void Delete(string path)
{
    DirectoryInfo DirDel = new DirectoryInfo(path);
    DirDel.Delete();
}

```

Can you tell me the problem in this code?

Answer: 
It is not clear from your question, where you have that folder, if it is on the client side, then i think it is not possible.

If it is on the server side you could use a link button instead of an anchor tag to run the code behind function

If you cant use the link button for some reason you could use JavaScript ajax calls to call the code behind function.
Here is a [code project article](http://www.codeproject.com/KB/aspnet/CallCodeBehindByJS.aspx), that may help you
You should use a LinkButton to get the same look as the , but you need your code to be execute on server side as the PostBack for your LinkButton.

The code you have here will make a call to a client-side script.