Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am having treeview and Linkbutton on my page, on page_load i want to determine whether the postback is from Linkbutton or Treeviw.
Plz help.
Posted

1 solution

HI..@Deepak


Very good question..
You can use the following page mathod for this


suppose you have link button with id "lnktest"

C#
string ctrlname = Page.Request.Params["__EVENTTARGET"];
           if (ctrlname.Contains("lnktest"))
{
////////////////place your activities
}

else
{
////////////////place your activities
}


Hope it will help you

Thanks
 
Share this answer
 
v3
Comments
Mohamed Mitwalli 4-Apr-12 3:12am    
Hi , Check on the ctrlname if it's null because it well be null
string ctrlname = Page.Request.Params["__EVENTTARGET"];
if (ctrlname != null)
{
if (ctrlname.Contains("LinkButton1"))
{
////////////////place your activities
}
else
{
////////////////place your activities
}
}
deepakaitr12345 4-Apr-12 3:17am    
yes correct you can customize as you want,no doubt in it.

Thanks
Mohamed Mitwalli 4-Apr-12 8:41am    
your welcome :)
Reza Ahmadi 4-Apr-12 3:23am    
Nice!
Deepak Manuja 4-Apr-12 7:56am    
get it work by Request.Form("__EVENTTARGET").

Thanks for help!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900