C# .NET - how to create user control in asp.net?

Asked By mohamed ghows on 16-Sep-14 08:30 AM
need to create user control for date function so..we can use anywhere on the project with calling this user control instead of calling the whole date function.
Robbe Morris replied to mohamed ghows on 16-Sep-14 08:44 AM
So, right click in Visual Studio and add the user control along with its code.

Then, in each page that wants to you use it, you register it above the Page tag (or event in your master page).  I like to do this with javascript to make 100% sure the client always gets the latest code.

<%@ Register tagprefix="MasterScript" Tagname="Files" src="~/Scripts/MasterScript.js.ascx"

<%@ Page .... %>

somewhere in your page, you place the control on the form:

<MasterScript:Files ID="MasterScriptJS" runat="server" />