0

I'm using a hyperlink like this to delete a directory when it is clicked.

 Response.Write("<a href= delete.aspx?path=" + 
     directory.FullName + ">DELETE </a>");
    }

But for this I'm being redirected to delete.aspx.Can I do it like button where path will be passed as parameters for the onclick function.

2
  • You mean that you want to delete the directory by executing the "delete.aspx" page but you don't want the user to see that page ? right ? Commented Jun 21, 2011 at 6:15
  • No,if it possible I want to do it in the same page with a function. Commented Jun 21, 2011 at 6:19

4 Answers 4

1

In the "Delete.aspx" page you must be fetching the query string value and in the page load, you must be having the code to delete the directory.

Now if you don't want to do this in the "Delete.aspx" page, add a button to the current page, then just move the code present in page load of "Delete.aspx" to the button click event of the current page(in which you have the hyperlink) and use the directory value(global value) in the button_click function.

Sign up to request clarification or add additional context in comments.

3 Comments

There is a problem in this why because I have so many directories in the page when it is clicked it should execute.
@ILLUMINATI7590 - If you want the button to look like a hyperlink then you can use a link button instead.
I can use a button but I want to print the directory structure so it wont be good to add buttons after every directory.
1

<asp:LinkButton /> with onclick event and CommandName and CommandArguments properties?

Comments

0

You can create the ASHX (Handler Page) instead of ASP.NET page. And also see this document.

2 Comments

I said create ASHX handler, and link to the handler instead of ASP.NET page. (not ASAX)
Actually I want it to look like hyperlink and work like a button.
0

are you looking for,

string page = "delete.aspx";

Response.Write("<a href= "+page+"?path=" +directory.FullName + ">DELETE </a>"); 

you can decide the value for page string

1 Comment

I didn't understand what you are saying? It's almost same as my code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.