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

Posted by Blake on 11/19/2013


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");