Hi All,
I got a functionality like below. Please share your experience or thoughts.
I have a user control and it has one text box and 2 buttons (add, remove). User control will be added dynamically based on functionality. But How to know add, remove id controls in .aspx (Page_load) function to know which button user has clicked?
If anybody has real time experience on this please share your thoughts and please do not provide any links as i already googled in the internet.
Regards,
Sudheer

Kunal VaishyaPosted Dec 3, 2014, 12:49 AM
If you want to implement click event in client then you can use "closest" function of Jquery, which is help you to find nearest control.
Example:
$(document).ready(function(){
$("span").closest("ul").css({"color":"red","border":"2px solid red"});
});
Reference : http://www.w3schools.com/jquery/traversing_closest.asp
Regards,
Kunal.
Joginder BangerPosted Dec 1, 2014, 4:51 AM
try this code may be it help. I have testing this code on my machine.
if (IsPostBack )
{
if (!string.IsNullOrEmpty(Request.Form[Button1.UniqueID]))
{
var text = "Button 1 clicked";
}
if (!string.IsNullOrEmpty(Request.Form[Button2.UniqueID]))
{
var seondtext = "Button 2 clicked";
}
}