Android Popup box/Dialog box code example - Java

When Developing an Android application, sometimes you want to have confirmation on the action done by the user. Using a popup box or dialog box will help to get the user's intention on what are they doing.  Here is the sample code to use the popup box/dialog box to show a message to the user.  Full Code example. import; import; import android.content.DialogInterface; import android.os.Bundle; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); } @Override public void onBackPressed(){ ShowMessageExit("Are You Sure You Want To Quit?"); } private void ShowMessageExit(String Message){ new AlertDialog.Builder(this) .setMessage(Message) .setPositiveButton(android.R.str

How to create DataGrid or GridView in JSP - Servlet

Hi there, today I will like to share my knowledge on creating basic Datagrid in JSP. This is my solution but not a permanent solution in all other cases. Maybe you can enhance this code to achieve your own objective. In this tutorial, I will use basic servlet and JSP. Note: In this tutorial, I will use this library:- MySQL JDBC Driver JSTL 1.1 the project will run on source JDK 7 This is the database table DROP TABLE IF EXISTS `blogtest`.`usersprofile`; CREATE TABLE  `blogtest`.`usersprofile` (   `userid` varchar(30) NOT NULL,   `firstName` varchar(45) NOT NULL,   `lastName` varchar(45) NOT NULL,   `emailAddress` varchar(45) NOT NULL,   PRIMARY KEY (`userid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `usersprofile` VALUES ('Ahmad','Ahmad','Ahmad',''), ('Ahmad1','Ahmad1','Ahmad1',''), ('Ahmad10','Ahmad10','Ahmad10',''), ('Ahmad11&#

Cannot Serialize The Data Table - Web Service

System.InvalidOperationException: There was an error generating the XML document. --->  System.InvalidOperationException: Cannot serialize the DataTable. DataTable name is not set. The error will occur when you create a method in web service (.asmx file) with return type " DataTable ". For Example like below:     [WebMethod]     public DataTable test1()     {         DataTable testTable = new DataTable();         return testTable;     } The Example above will lead to the Error " Cannot Serialize The Data Table " This error because the method in WebService tries to return the result of DataTable to the client, but the DataTable does not have their own name. So the quick solution for this error has put the name for DataTable like example : The Solutions      [WebMethod]      public DataTable test1()     {           DataTable testTable = new DataTable(" Table1 ");           return testTable;      } With this simple solution will solved the issue mentioned

Send email from code behind - Kentico Xperience CMS

Overview Sometimes when developing websites you may need to send emails to recipients depends on the scenario. For example, your client wants to have integration with a 3rd party system. So you did an integration and the client want every time the integration failed, send an email to the web editor to check. So how you can achieve this in Kentico Xperience CMS. Create an Email Template. First, you need to have an email template in Kentico Xperience CMS. You can do this by open the Email Template module and create a new template. The steps described in this link .

Sample code to check Kentico Xperience Object alternative form.

Kentico Xperience is a powerful CMS that build from 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 / c#

Before start you need to convert your json data to c# class. You can achieve this by using online tools like : Go to : Paste your Json data into box and click Generate Button. Copy the code generated and create Class file in your solution. After finish convert json data to c# class, Copy the code below. Example JSON Data 1: { 2: "name":"apicode", 3: "email": 4: [ 5: "","" 6: ], 7: "websites": 8: { 9: "home_page":"http:\/\/", 10: "blog":"http:\/\/" 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

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 &