ASP.NET: How to retrieve an argument manually wired up with GetPostBackClientHyperlink


You have wired up a link/button on the page with Page.ClientScript.GetPostBackClientHyperlink, passed it an argument and you need to retrieve that argument whenever the event is fired for the said link/button.


In the event in question, you will want to put a check in to make sure that the __EVENTTARGET is the UniqueID of control in question and then you will want to pull out the __EVENTARGUMENT value form the request. Here are examples in VB.Net and C#:


Dim arg As String = ""

If Request.Params("__EVENTTARGET") = linkDeleteGoal.UniqueID Then
    arg = Request.Params("__EVENTARGUMENT")
End If


string arg = "";

if (Request.Params("__EVENTTARGET") == linkDeleteGoal.UniqueID)
    arg = Request.Params("__EVENTARGUMENT");

Leave a comment

Please note that we won't show your email to others, or use it for sending unwanted emails. We will only use it to render your Gravatar image and to validate you as a real person.