Add A web user control file and write code for that control
Add Place Holder in .aspx file
<asp:PlaceHolder ID="ControlPlace" runat="server"></asp:PlaceHolder>
Add line <%@ Reference Control="~/UserControls/ScoreCardControl.ascx" %> in .aspx file in which you want to use the web user control.
In .aspx.cs file-
make object of user control in .cs file
private UserControls_ScoreCardControl controlObj = new UserControls_ScoreCardControl();
load control
controlObj = (UserControls_ScoreCardControl)LoadControl("~/UserControls/ScoreCardControl.ascx");
ControlPlace.Controls.Add(controlObj);
Add Place Holder in .aspx file
<asp:PlaceHolder ID="ControlPlace" runat="server"></asp:PlaceHolder>
Add line <%@ Reference Control="~/UserControls/ScoreCardControl.ascx" %> in .aspx file in which you want to use the web user control.
In .aspx.cs file-
make object of user control in .cs file
private UserControls_ScoreCardControl controlObj = new UserControls_ScoreCardControl();
load control
controlObj = (UserControls_ScoreCardControl)LoadControl("~/UserControls/ScoreCardControl.ascx");
ControlPlace.Controls.Add(controlObj);
No comments:
Post a Comment