Click here to Skip to main content
15,879,096 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
im developing a mobile appln using asp.net & c#
im using a master page
now i want to write button click event code for master page button in content page how can i?
Plz help me
Posted
Updated 9-Jul-14 18:55pm
v2

1 solution

In your master page's code behind replace the protected keyword on the event handler to public.
public void LinkButton1_Click(object sender, EventArgs e)
{
    //Do Stuff Here
}

IN your content page use the Master Type Directive
<![CDATA[<%@ MasterType VirtualPath="~/masters/SourcePage.master"" %>]]> 

In the code behind for the content page call the Master event handler as follows
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
    this.Master.LinkButton1_Click(sender, e);
}


See some good links for this point. And go through this you will bit clear more
interacting-with-the-content-page-from-the-master-page-cs[^]
 
Share this answer
 
Comments
Member 10924493 10-Jul-14 1:28am    
thank you for reply,but it is not working and one thing i have different functionality for the same button in all content pages
Bhushan Mehetre 10-Jul-14 1:32am    
then use case and add one more parameter to the method to identify functionality....

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