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: 
You're rendering clientside code, expecting it to call serverside code. This will never work, clientside always happens on their machine, not on your server.

What you want is to use a [LinkButton](http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.linkbutton.aspx) control, e.g.:

```
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>LinkButton Example</title>
    <script language="C#" runat="server">

    protected void LinkButton_Click(Object sender, EventArgs e) 
    {
        // Code to delete directory
    }

    </script>    
</head>
<body>

   <form id="form1" runat="server">
       <h3>LinkButton Example</h3>

       <asp:LinkButton id="LinkButton1" 
           Text="Click Me" 
           Font-Names="Verdana" 
           Font-Size="14pt" 
           OnClick="LinkButton_Click" 
           runat="server"/>

       <br />

       <asp:Label id="Label1" runat="server" />

    </form>    
</body>
</html>

```
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.