Question: How can I get the id of the control which causes `PostBack` in asp.net. I uses 

```
document.getElementById("__EVENTTARGET")

```

But it is giving only `objectHtmlInputElement` Not a complete ID. How Can I get this in javascript only and not in code behind. I want this for focusing on that element after postback. Please help..

Answer: 
You can use this function mentioned in this [blog](http://geekswithblogs.net/mahesh/archive/2006/06/27/83264.aspx) to get postback control id, store this id in hiddenfield and use JS to get that id from hiddenfield

```
 protected void Page_Load(object sender, EventArgs e)
    {    
        if (Page.IsPostBack)
           HiddenField1.Value = getPostBackControlName();
    } 

private string getPostBackControlName()
{
    Control control = null;
    //first we will check the "__EVENTTARGET" because if post back made by       the controls
    //which used "_doPostBack" function also available in Request.Form collection.
    string ctrlname = Page.Request.Params["__EVENTTARGET"];
    if (ctrlname != null && ctrlname != String.Empty)
    {
        control = Page.FindControl(ctrlname);
    }

    // if __EVENTTARGET is null, the control is a button type and we need to
    // iterate over the form collection to find it
    else
    {
        string ctrlStr = String.Empty;
        Control c = null;
        foreach (string ctl in Page.Request.Form)
        {
            //handle ImageButton they having an additional "quasi-property" in their Id which identifies
            //mouse x and y coordinates
            if (ctl.EndsWith(".x") || ctl.EndsWith(".y"))
            {
                ctrlStr = ctl.Substring(0, ctl.Length - 2);
                c = Page.FindControl(ctrlStr);
            }
            else
            {
                c = Page.FindControl(ctl);
            }
            if (c is System.Web.UI.WebControls.Button ||
                     c is System.Web.UI.WebControls.ImageButton)
            {
                control = c;
                break;

            }
        }
    }
    return control.ID;
}

```
Use `document.getElementById('__EVENTTARGET').value`