Trying to add a Javascript on a hyperlink click event. Here, I get the Name of the hyper link, but nothing happens when i try to click on the hyperlink.
tblCell = new HtmlTableCell();
List<string> liEmailIdsForCC = new List<string>();
if(some condition)
{
liEmailIdsForCC .add("someitem");
}
HyperLink hpOwnerName = new HyperLink();
hpOwnerName.Text += string.Format("({0}) ", "FullName");
string args = string.Format("{0},{1}"
, this
, liEmailIdsForCC
);
var onClick = String.Format("javascript:OnNameClick({0});return false;", args);
hpOwnerName.Attributes.Add("onclick", onClick);
tblCell.Controls.Add(hpOwnerName);
Now, in this javascript, I am just trying to alert the first item in the list
function OnNameClick(sender, list) {
alert(li[0]);
}
thisto a string, which will not be what you want. And as @WilfredoP states, in your javascript functionlidoesnt exist. I think you meanlist