Without seeing any details of your error, I can only assume that it's the server side method signature that's the problem. Server side events have a different signature, for example:
protected void Something_Click(object ssnder, EventArgs e){
}
And you'd call it like this:
<a id="aref" href="MyCart.aspx" runat="server" onserverclick="Something_Click">Add To Cart</a>
That still leaves you with the problem of passing the ProductId to the server side method. I wouldn't use a Html tag in that case. Use an ASP.net LinkButton and assign the ProductId to the CommandArgument property of the LinkButton.