Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a User Control (name as A.ascx ) And in this user control one Method is BindData(),

I want to access that method to Parantpage (name as B.aspx),
which is very simple:
Like this (at code behind of B.aspx)
A.BindData();


Now My Problem Start:
Problem is mY B.aspx page use One Master page(C.master),
so if i use master page with B.aspx page then i am unable to call method like this:
A.BindData(); which give error:


so what can i do ????

i Find Similar prob at::
http://stackoverflow.com/questions/15019598/call-user-control-method-in-master-page-from-content-page[^]


This link Give One solution,

But this solution not work because:
my user control not place at master page then how i access That user control method at master page code behind:

Plz Help....
Posted
Updated 27-Sep-13 0:11am
v5
Comments
Brij 27-Aug-13 7:18am    
I am not sure what is the actual issue. If you can access a user control's method from B.aspx. Similar way you can access if B.aspx uses any master page.

Where did you register user control. and from where you are trying to call it method?
Arun kumar Gauttam 27-Aug-13 8:57am    
when i inherit master page in content page then, i am unable to write

A.BindData(); because in that condition It will give error...
Brij 27-Aug-13 9:18am    
Seems you've asked wrong question. Seems you are trying to access A.BindData() from master page code behind. Am I right?
Arun kumar Gauttam 27-Aug-13 9:31am    
1. Question is very clear that i want to use User control method At Any Content page(and page Inherited master page)

2. For this i search at google and Find one trick(Solution) that if i access user control method at master page and then after call that master page method to my content page,
then,

If you have anser of first question then suggest me, Other wise i will Try Second trick,

Which is also suggest by pradippatel99 (at the solution 1 of this question Givin below)

1 solution

Hi
please set below directive in inherited page from master page like

<%@ MasterType VirtualPath="~/Site.Master" %>


and add C# code in inherited page code behind file

Master.callUsercontrolMethod();


below is master page method which call usercontrol's method

C#
public void callUsercontrolMethod()
       {
           usercontrol.BindRepeater();
       }



it really works
 
Share this answer
 
Comments
Arun kumar Gauttam 27-Aug-13 9:05am    
thank, for solution,
But i am unable to use
usercontrol.BindRepeater(); At master Page because usercontrol not find at master page:

i am also add <%@ MasterType VirtualPath="~/Site.Master" %> At contant Page(which inherited Master page), there is any other idea for this problem..
pradippatel99 27-Aug-13 9:08am    
can you tell me where and how usercontrol is registered in master page?
Arun kumar Gauttam 27-Aug-13 9:36am    
i am not registered any use control at master page,
i just add <%@ MasterType VirtualPath="~/Site.Master" %> to Content Page and i thing master page automatically Access the user control,

But it is not work...
so plz suggest me what can i do,(How i registered user control at masterPage so i access That user control At code behind of master page )
pradippatel99 29-Aug-13 1:45am    
add in master page
<%@ Register Src="~/WebUserControl1.ascx" TagName="RepeaterControl" TagPrefix="uc1" %>

now you can use usercontrol as below in
<uc1:RepeaterControl ID="usercontrol" runat="server" />

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