Reputation: 199
I have a asp ImageButton
which has its corresponding Onclick
event like OnClick="imgSubscriberInformation_Click"
, this imagebutton is inside a td
, so I want to call imgSubscriberInformation_Click(object sender, ImageClickEventArgs e)
on click of td
, how can I do this? the td
doesnot support serverside click event.
Also, I need the imageURL
of imagebutton
to be passed on every click.
aspx code:
aspx.cs code:
protected void imgSubscriberInformation_Click(object sender,ImageClickEventArgs e)
{
hidCtrl.Value = "false";
if (hidSubscribeInfo.Value == "")
{
if (imgSubscriberInformation.ImageUrl == "Images/downarrow.png")
{
LoadUserControl();
PopulateData();
imgSubscriberInformation.ImageUrl = "Images/uparrow.png";
}
}
else if (hidSubscribeInfo.Value != "")
{
imgSubscriberInformation.ImageUrl = "Images/uparrow.png";
LoadUserControl();
PopulateData();
hidSubscribeInfo.Value = "";
}
}
Upvotes: 0
Views: 1538
Reputation: 199
Guys i found a solution, i moved the onClient click function to TD and inside the javascript function i did this "__doPostBack("imgSubscriberInformation", "");" this will call the click event of the imageButton. Thanks for your time.
Upvotes: 0
Reputation: 4746
You could do this entirely with jQuery/javascript. Grab all the TD's (or specify them by class) and assign to them an onclick event to trigger the click of the image button within.
//all TD's
$("#mytable td").on( "click", function() {
$(this).find('img').trigger( "click" );
});
//or
// by class
$(".tdWithImgButton").on( "click", function() {
$(this).find('img').trigger( "click" );
});
Upvotes: 2