Wednesday, 26 March 2014

On Your website Adding Custom Code




The simplest path how to embed custom code into an portal engine-based site is utilizing standard ASCX client controls. This subject will demonstrate to you industry standards to do this. Assuming that you are not acquainted with Visual Studio development can avoid this topic.

Example on Current Time 

In this case, we will make a simple user control (ASCX) utilizing Visual Studio and incorporate it into our home page.

Open the site project utilizing the Webproject.sln file that is put in the folder where you deployed the site. Right-click the web project root in the Solution Explorer window and click the Add new item... option. Decide to make another Web User Control and set its name to Gettime.ascx. You can set the programming language option to either Visual C# or Visual Basic.



Select Add. Switch to the Design tab, drag and drop the following controls and set their properties:
Button control:
ID: Button1
Text: Get time
Label control:
ID: Label1
Text: <clear the value>
Add the following code to the Button1_Click method, Double-click the Get time button :
[C#]
Label1.Text = DateTime.Now.ToString();

[VB.NET]
Label1.Text = DateTime.Now.ToString()

Saveboth the ASCX and ASCX.CS files.
Including the user control on the page Log in to Kentico CMS Desk, chose the Home page and click Design. Add () a General -> User control web part to the Main zone. Enter the following value into the web part's User control virtual path property: ~/GetTime.ascx
Web parts versus User controls The ~ character represents the root of your web application. Click OK. Click the Live site mode and now you can see the user control inserted onto the page. When you click the Get time button now, the current date and time is displayed next to the button:

An alternate choice how to embed custom code onto a page is to make your own particular web part. A web part is essentially additionally an ASCX user control, yet it inherits some institutionalized properties and strategies from the CMSAbstractWebPart class. You should build web parts in situations where you have to make re-usable, parameterized user controls. The development of web parts is described in the next chapter.


Ray Business Technologies Pvt Ltd, www.raybiztech.com , is a global Information Technology (IT) Services and Solutions company. Raybiztech offers comprehensive end-to-end IT Services for Business Application Development & Maintenance, Enterprise Solutions, Testing & Quality Assurance, Embedded Systems, Cloud Computing and IT Infrastructure Management to organizations in the Banking & Financial Services, Insurance & Healthcare, Life Sciences, Manufacturing, Retail, Distribution & Logistics, Media & Entertainment, Leisure & Travel, Communication, Energy & Utilities, Federal Government verticals and Independent Software Vendors. Raybiztech's innovative IT Solutions in Enterprise Resource Planning (ERP), Enterprise Portals and Content Management (EPCM), Customer Relationship Management (CRM), and Enterprise Mobility including Product Development and Life-Cycle Support, have resulted in significant strategic and cost advantage for their clients worldwide.
Raybiztech is now leading the way in powering next-generation enterprises with its Cloud, Mobility, Big Data and Social Media solutions. Our excellent team of Technology Professionals work with enterprise clients in North America, Latin America, Australia, Europe, Middle East and Asia.




No comments:

Post a Comment