Posts

Showing posts from October, 2017

Sample code to check Kentico Xperience Object alternative form.

Kentico Xperience is a powerful CMS that build from asp.net framework. The CMS have an eCommerce solution, Intranet and collaboration, Online Marketing, and Content management that make Kentico Xperience is the most popular CMS nowadays. In Kentico Objects, you can create alternative forms allow you to create different versions of existing forms. The alternative forms can then be used instead of the default form in the system's administration interface or on the live site. This is the snippet for Kentico version 8.xx to check if the page type has an alternative form. Code Behind 1: public bool CheckIfPageTypeHaveAlternativeForm(string EditFormName,string classID) 2: { 3: bool haveForm = false; 4: if (classID != "") 5: { 6: if (CMS.DocumentEngine.CMSDataContext.Current.AlternativeForms.GetSubsetWhere("FormClassID = " + classID).Count > 0) 7: { 8: var DataInfo = CMS.DocumentEngine.CMSD...

JSON & DataTable in asp.net / c#

Before start you need to convert your json data to c# class. You can achieve this by using online tools like :  http://json2csharp.com/ Go to :  http://json2csharp.com/ Paste your Json data into box and click Generate Button. Copy the code generated and create Class file in your asp.net solution. After finish convert json data to c# class, Copy the code below. Example JSON Data 1: { 2: "name":"apicode", 3: "email": 4: [ 5: "apicode@gmail.com","apicode@gmail.com" 6: ], 7: "websites": 8: { 9: "home_page":"http:\/\/apicode.blogspot.com", 10: "blog":"http:\/\/apicode.blogspot.com" 11: } 12: } JSON Class after converted 1: public class Websites 2: { 3: public string home_page { get; set; } 4: public string blog { get; set; } 5: } 6: public class RootO...

Javascript show clock in webpage example

Image
This example show how to insert clock on the website which is not static clock, but like a digital clock. Script for Creating Clock 1: <script type="text/javascript"> 2: function updateClock() { 3: var currentTime = new Date(); 4: var currentHours = currentTime.getHours(); 5: var currentMinutes = currentTime.getMinutes(); 6: var currentSeconds = currentTime.getSeconds(); 7: // Pad the minutes and seconds with leading zeros, if required 8: currentMinutes = (currentMinutes < 10 ? "0" : "") + currentMinutes; 9: currentSeconds = (currentSeconds < 10 ? "0" : "") + currentSeconds; 10: // Choose either "AM" or "PM" as appropriate 11: var timeOfDay = (currentHours < 12) ? "AM" : "PM"; 12: // Convert the hours component to 12-hour format if needed 13: currentHours = (currentHours ...