Saturday 15 February 2014

c# - Function of user-control type in a master page -



c# - Function of user-control type in a master page -

i have user command file called lcont.ascx. lcont has been dragged master page.

now want create public function of type lcont in master page, masterpage.cs not recognize lcont (saying `the type or namespace lcont couldnt found(are missing using directive or reference) when build).

why? used approach previously, , worked.

here's master page:

<%@ register src="usercontrol/lcont.ascx" tagname="lcont" tagprefix="uc1" %> <div class="container" > <form id="form1" runat="server"> <div class=" row "> <div class="col-lg-12"> <uc3:header id="header1" runat="server" /> </div> </div> <div class="col-lg-3" style=" background:rgb(245,245,245); margin-right:1%; min-height:500px; " > <uc1:lcont id="lcont1" runat="server" /> </div>

here's code behind:

public lcont getlcont() { homecoming lcont1; }

actually want access user control's id in aspx page. user command of course of study included in master page. besides this, else need around problem?

if have implemented lcont in master page, certainly can create public function of type lcont.

the way doing absolutely right - how should done.

so far know, think problem in user control's class name. lcont have used in public function should class name of lcont user control; class name not user control's file name. mean if file name lcont.ascx, assume class name lcont - in case code work; class name foldername_usercontrolfilename - in case code won't work.

so should done?

check first line of lcont.ascx page. there property called inherit. check value, should lcont not foldername_lcont. check class declaration in lcont.ascx.cs file. public partial class foldername_lcont : system.web.ui.usercontrol. alter public partial class lcont : system.web.ui.usercontrol.

now master page recognize lcont.

for more on this, see http://wp.me/p2frvp-3d.

c# asp.net user-controls

No comments:

Post a Comment