__doPostBack does not work in chrome and safari

advertisements

__doPostBack() function works in FF and IE,but not working in safari and chrome. I have following code in my asp.net c# application

ASPX Code


<a href="www.myAddress.com/abcdef.html" onclick="javascript:SetPosition(); ">Click here</a>

JS Function


function SetPosition() {
        __doPostBack('ahref', 'link');
}

CS Code


protected void Page_Load(object sender, EventArgs e)
{
            if (!IsPostBack)
            {
                // Other code is here
            }
            else if (Request.Params["__EVENTARGUMENT"] != null && Convert.ToString(Request.Params["__EVENTARGUMENT"]).Trim() == "link")
            {
                Session["TopPossition"] = "9999";
            }
}


I believe you need to pass the server control id as the EventTarget and not the client id when you use __doPostBack call. Try changing the __doPostBack call as so...

<a id="someclientid" name="someuniqueid" href="javascript:void(0);" onclick="__doPostBack('someuniqueid', '');">val</a>

By default, controls use __doPostBack to do the postback to the server. __doPostBack takes the UniqueID of the control (or in HTML, the name property of the HTML element). The second parameter is the name of the command to fire.