Wednesday, 4 November 2015

Dialog box confirmation before exit android app.

Leave a Comment
This is the code to trigger dialog box before you exit the application in android. private void ShowMessageExit(String Message){ new AlertDialog.Builder(this) .setMessage(Message) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { android.os.Process.killProcess(android.os.Process.myPid()); System.exit(0); } }) .setNegativeButton(android.R.string.no,...
Read More...

Saturday, 3 October 2015

How to make request to webservice with soap message - asp.net /C#

Leave a Comment
If you have webservice and want to call the web service from your c# code, you can try to use this method example. Code Behind HttpWebRequest request = (HttpWebRequest)WebRequest.Create(<web service address>); request.Headers.Add("SOAPAction", "http://tempuri.org/" + <web service method>); request.ContentType = "text/xml;charset=\"utf-8\""; request.KeepAlive = false; request.Timeout = 300000; // - in millisecond. (5 minit) request.Method = "POST";...
Read More...

Method snippet to remove space between words - asp.net

Leave a Comment
This is the method that can use in c# application or asp.net to remove space between words. Example : Hello World  --> HelloWorld Method  /// <summary> /// Method to remove space in a string example : Hello world --> HelloWorld /// </summary> /// <param name="data"></param> /// <returns></returns> public static string removeSpace(string data) { Regex r = new Regex(@"\s+"); string _temp = ""; _temp...
Read More...

Check web config file either encrypt or not.

Leave a Comment
This is example how to check if web.config file is encrypt or not. refer this article to encrypt and decrypt web config file. The example will check web config file for 3 section which is ConnectionString, AppSetting, and system.web/authentication . Code Behind private static string[] sectionName = { "connectionStrings", "appSettings", "system.web/authentication" }; public static string[] SectionName { get { return sectionName; } set { sectionName...
Read More...

Kentico 8.xx - Snippet to check if page type have alternative form name

Leave a Comment
This is the snippet for Kentico version 8.xx to check if page type have alternative form. Code Behind public bool CheckIfPageTypeHaveAlternativeForm(string EditFormName,string classID) { bool haveForm = false; string strEditFormName = ValidationHelper.GetString(EditFormName, ""); if (classID != "") { if (CMS.DocumentEngine.CMSDataContext.Current.AlternativeForms.GetSubsetWhere("FormClassID = " + classID).Count > 0) { ...
Read More...

delete top N rows mssql

Leave a Comment
This example show how to delete top N rows in mssql, where N is dynamic number. It could be 1000, 100, or 10 . ;WITH CTE AS ( SELECT TOP 1000 * FROM [table_name] ORDER BY a1 ) DELETE FROM CTE 1000 is the example number. [table_name] is the table you want to delete a1 is just a example of sort by column a1 Tanks to stack overflow for this help : http://stackoverflow.com/questions/8955897/how-to-delete-the-top-1000-rows-from-a-table-using-sql-server-2008 By Mohd Zulkamal NOTE : – If You have...
Read More...

How to read JSON Data and convert to DataTable - asp.net / c#

Leave a Comment
This is example how to read JSON Data using c# code. First before you start coding, please read this post on how to convert json data to c# class. How to convert JSON data to Class - C# After finish convert json data to c# class, write this code to read your json data. Example JSON Data { "name":"swengineercode", "email": [ "swengineercode@gmail.com","swengineercode@gmail.com" ], "websites": { "home_page":"http:\/\/swengineercode.blogspot.com",...
Read More...

How to convert JSON data to Class - C#

Leave a Comment
Today i found one very good tools to convert JSON data to c# class. Please go to this link : http://json2csharp.com/ You just paste the json data, and it will give you the class for each element in the json data. Example JSON Data : Note : This example JSON data from TripAdvisor API. { "address_obj": { "street1": "Lot PTB22819 ", "street2": "Jalan Skudai", "city": "Johor Bahru", "state": "Johor", "country": "Malaysia", "postalcode": "80200", "address_string": "Lot PTB22819...
Read More...

How to access webpart method from another webpart - Kentico

Leave a Comment
This tutorial is to show how to access web part method from another webpart. This situation basically when you use repeater(webpartA) and inside repeater transformation you call another User control / webpart(webpartB). Everytime the you trigger event on the webpartB (ie: click, change value, etc), you want to refresh the webpartA value. But you cannot access the method directly. Code Behind repeater / WebartA Override OnInit Event protected override void OnInit(EventArgs e) { RequestStockHelper.Add("WebPartB",...
Read More...

Example to force form control to failed in Kentico BizForm - Code Behind

Leave a Comment
This is a example to manually force stop the bizform to continue processing save data and show error message to the Field Form Control. Note this is just example. You may use this approach to set very complex validation on the Field in BizForm. OnLoad Method protected override void OnLoad(EventArgs e) { viewBiz.OnAfterSave += viewBiz_OnAfterSave; viewBiz.OnBeforeSave += viewBiz_OnBeforeSave; base.OnLoad(e); } ...
Read More...

Compress and decompress stream object in asp.net - Deflate

Leave a Comment
This is a snippet code to provides methods and properties for compressing and decompressing streams using the Deflate algorithm. abstract class Stream using System; using System.IO; namespace CompressionMethod { /// <summary> /// Provides a generic view of a sequence of bytes. /// </summary> public abstract class Stream : IDisposable { #region "Properties" /// <summary> /// Gets or sets system stream. /// </summary> public abstract...
Read More...

Compress and decompress stream object in asp.net - GZip

Leave a Comment
This is a snippet code to provides methods and properties for compressing and decompressing streams using the GZip algorithm. abstract class Stream using System; using System.IO; namespace CompressionMethod { /// <summary> /// Provides a generic view of a sequence of bytes. /// </summary> public abstract class Stream : IDisposable { #region "Properties" /// <summary> /// Gets or sets system stream. /// </summary> public abstract...
Read More...

How to do Search Condition on Kentico Smart Search Module Using API

2 comments
Below is an example of using Smart Search API module in Kentico. The API Example inside kentico not telling this, but i was able to figure out the way.  Kindly have a try on the snippet example  Smart Search Module API - Search With Condition  public void SmartSearchWithCondition(string searchText,string ClassName,string extraCondition) { DocumentSearchCondition docCondition = new DocumentSearchCondition(); docCondition.ClassNames = ClassName; docCondition.Culture = "en-US";...
Read More...

Android on click list item open in dialog

Leave a Comment
Today i want to show how to open list item in dialog. For this tutorial you need to have :- Dialog design view_item.xml MyDialogFragment.java class OnClick Event to call dialog. Announcement.java Class AnnouncementHelper Class OnCreateView Method view_item.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"...
Read More...

How to target specific sub element Jquery

Leave a Comment
Today i have experience difficulty to target specific sub element in my html document. So i would like to share my solution that i have. Example HTML : <div class="content"> <span>element one</span> <span>element two</span> <span>element three</span> <span>element four</span> </div> The problem is how to append text on the third sub element under div with class content....
Read More...

Open url with section targeting with jQuery and HTML 5

Leave a Comment
Recently I have some project that require to target certain section in my HTML 5 project. after do some testing and research on google how to do it, finally I think this snippet is the best that can work in most modern browser. Lets see the code . HTML sample  <section id="mainIntro" class="" target-url="<target url>"> : : : </section> ...
Read More...

how to select date time using calendar android

Leave a Comment
This tutorial shows how to set date time in android app when you click on the textbox. Note : This example using Andorid Studio to create project. Im using Sample Blank Activity with Fragment sample. Step By Step  Add One EditText on the fragment Create DateTimeFragment.java class Copy Paste DateTimeFragment.java class below. Override onViewCreated event from fragment Done. Full Source Code of MainActivity class + Fragment / placeholder class package com.test.selectdatetime; import android.app.Dialog;...
Read More...

Handle Error Modes in ASP.NET redirec to proper page - Web.config

Leave a Comment
Most of the website and web application must have error handler. Some beginner might question what are the error handler should have in one website. Below are the basic error handler that you need to set in the website : Page Not Found - 404 Internal server Error - 500 Access Denied - 403 The above error page must have in one website. This is because when application catch error, the end users will see asp.net designed page without details error information that might not user friendly for the end users. To handle this errors,...
Read More...

How to create multiple tab with different fragment / view - Android app

Leave a Comment
Most beginner android developer wonder how to create different fragment for each tab in their android app. Please follow this tutorial to create basic android app with 3 tab before continue with this tutorial. ( http://swengineercode.blogspot.com/2015/05/how-to-create-multiple-tab-on-android.html ) This example using android studio. Kindly download the studio here ( https://developer.android.com/sdk/index.html ) Step By Step  1....
Read More...

Friday, 2 October 2015

How to create multiple tab on android app

Leave a Comment
This tutorial to show how to create multiple tab on Android App. This example using android studio. Kindly download the studio here ( https://developer.android.com/sdk/index.html ) Step By Step 1. Open Android Studio. 2. Choose Start New Android Studio Project ...
Read More...

Kentico 7 Get Current Date Time using macro

Leave a Comment
In kentico 8, you can call macro method to show date time information just like C# code which is : {%DateTime.Now%} But for kentico version 7, you can not call date time in macro using above code. So i have wondering how to call the date time using macro? and also want to format the date time. Below is a example how you can show date time in kentico 7 using macro. Get Date Time {% CurrentDateTime%...
Read More...

Make Big project compilation faster - Optimize Compilation

Leave a Comment
Most of the web application nowadays are complex application that maybe have more than 50MB source code to deploy on the server and it will lead to the long compilation time around 3-10 minute depends on the server resources. Some will says, it still ok to wait the compilation since it only happen for the first time. What about require to change the source code with very minimal code of line.? Like one line only.? Do you still love to wait 3-10 minute. The answer is n...
Read More...

Jquery Mobile, document ready not fire.

Leave a Comment
Today i have experience some weird situation which i already put the alert script on my mobile html page, but the alert didn't show. The alert script not put at the homepage, but at the url provided, when click the button then will redirect current page to the new page with contain alert script. For me,this is so weird. No error on script. At the first place i though it was cache.. so i click on refresh button.. So i just assume it is cache. But after a while, it always need to refresh only show the alert message....
Read More...

Multiview + File Upload + UpdatePanel , selected file not upload to server

Leave a Comment
Recently I have developed some module to upload the file to server. In my code i have Update panel and also the multiview. Somehow the upload not working. So i though i was not set the full postback for upload process in the trigger section under update panel. But actually the full postback was set correctly. So i wonder, why the upload not work. Why server detected that no file submit to server. So i start investigate my code, and luckily i found the solution. The solution  I just need to set enctype attribute at the...
Read More...

Force Download File in ASP.NET

Leave a Comment
This is example how to force current HTTP Context Response to download file. Before that, you need to set path / folder in your web application to store file that you just created or pre set the file to download. In ASP.NET this is the way to set path. Since we can use tiddler("~") symbol to referring to the root with virtual path set from IIS. string pathFile = Server.MapPath(Request.ApplicationPath); ...
Read More...

Javascript to redirect page to search page with passing query string

Leave a Comment
This is a example method in javascript to redirect page searching page plus carry whatever value type in the textbox after press enter button or click submit button. Requirement JQuery library HTML <div class="input-group search-btn"> <input id="textSearch" type="text" onkeypress="keypressSearch(e);" class="form-control"> <span class="input-group-btn"> <button class="btn btn-default" onclick="return Search();return false;" type="button">SEARCH</button> ...
Read More...

Example Lock Dataset in C#

Leave a Comment
This is example how to lock your database or prevent data in dataset to changed (read only dataset). In large web application, you may have reference table in database, and the application no need to read on the reference table every time the application need to get reference. You can store the reference table in cache memory. But you afraid that the data might accidentally  changed by your code. This is the way to make your dataset lock / readonly. Lock Dataset method /// <summary> /// Makes the given...
Read More...

Combine / Union two dataset

Leave a Comment
This method is example to combine two dataset into single dataset. This method also called Union two dataset meaning that if both dataset contains same data, the combined dataset will not included. Method Union Dataset : /// <summary> /// Creates the union of two Datasets, the values are compared for uniqueness by the given ID column name. /// </summary> /// <param name="ds1">First DataSet</param> /// <param name="ds2">Second DataSet</param> /// <param...
Read More...

Splits the camel cased input text into separate words.

Leave a Comment
This is example method to split "Camel Cased" into seperated Words. Example Camel Cased ThisIsOneExample TomorrowIsWhatDay ThisIsAnotherExample ASPX Page <asp:Label ID="Label1" runat="server" Text="Camel Words"></asp:Label>: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br /> <br /> <asp:Button ID="Button1" runat="server" Text="Convert" onclick="Button1_Click" /> <br /> Preview : <asp:Literal ID="Literal1"...
Read More...

Detect request is a Crawler / bot or End user request

Leave a Comment
Some project might store some information where is the request come. This code snippet is show how you can determine the request is a crawler or not. Code Behind  /// <summary> /// Returns whether browsing device is search engine crawler (spider, bot). /// </summary> public bool IsCrawler() { if (HttpContext.Current != null) { HttpRequest currentRequest = HttpContext.Current.Request; return (currentRequest.Browser != null) &&...
Read More...

Detect Browser Name And Version

Leave a Comment
This is example in asp.net how to detect client browser and version. The method used in this example can work after copy paste in the Visual Studio. Aspx Code <br /> <h5> <asp:Literal ID="Literal1" runat="server"></asp:Literal> </h5> <p> &nbsp;</p> <p> &nbsp;</p> ...
Read More...

Example to remove all script block in HTML

Leave a Comment
This is example how to remove script block in HTML. This method will be very useful if you want to validate the html passed from input string do not have any script block. Example HTML have script block : <div> this is the information </div> <script>alert('Your computer have security vulnerable');</script> Example ASPX Code : Note : This html using Editor Controller in AjaxToolkit library <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> </asp:Content>...
Read More...

Monday, 9 February 2015

Send email in Kentico 8.xx

Leave a Comment
This is example method to send data in Kentico 8.xx Send email method using CMS.EmailEngine; using CMS.EventLog; ::: ::: public static class CustomClass {     public static void SendEmail(string EmailTemplateCode, MacroResolver mcr,string recipients)     {         EmailMessage msg = new CMS.EmailEngine.EmailMessage();         EmailTemplateInfo eti = EmailTemplateProvider.GetEmailTemplate(EmailTemplateCode, SiteContext.CurrentSiteID);       ...
Read More...

Turn off EventLogProvider from store update / delete / insert activity in Kentico

Leave a Comment
The event log stores information about all events that occur in the system. It is useful to view logged information if unwanted behavior occurs in the system and you want to find out where the problem originates or get additional details. But, some activities you don't want to be stored in database while you are developing Custom Webpart . This is the way how to turn off the for a while in your custom code block. Step by Step  Add "using CMS.Base;" Wrap your code block with this using block code. using (CMSActionContext...
Read More...

Subscribe to our newsletter to get the latest updates to your inbox.

Your email address is safe with us!




Founder of developersnote.com, love programming and help others people. Work as Software Developer. Graduated from UiTM and continue study in Software Engineering at UTMSpace. Follow him on Twitter , or Facebook or .



Powered by Blogger.