Posts

Creating Your First MVC 4 Application

Image
In this tutorial i will show the example on MVC 4. Follow this step to create new MVC Application on Microsoft Visual Studio 2010. Creating MVC 4 Project File >> New Project Choose ASP.NET MVC4 Web Application. (If you dont have MVC 4, Install it here ) On Project Template , choose Empty if you want to start from zero or choose Internet Application to start developement with default template. Choose View engine Razor. Click OK button Now you have create one project with MVC4 Solution  Adding First Controller Right click on the Controller folder under Solution Explorer Menu. Choose Add >> Controller Rename Controller Name to HomeController Since this is empty project, so under Scaffolding Options Template choose Empty MVC Controller Change The default ActionResult Index() like this         public string Index()         {             return "Hello World, This is my first MVC Application";         } Run the project, You should see the output on the browser lik

Decimal Manipulation in C#

This post will  show manipulation on the Data Type Decimal. //This is the hard code value for decimal   //without suffic m or M, the compiler thread the object as a double hence will cause error   decimal price = 10.1654M;   //Convert decimal to double   double priceInDouble = Convert.ToDouble(price); //output : 10.1654   priceInDouble = (double)price;//output : 10.1654   //convert to double with 2 decimal point,           priceInDouble = Math.Round((double)price, 2); // output : 10.17   //convert back to decimal   price = Convert.ToDecimal(priceInDouble);//output : 10.17   price = (decimal)priceInDouble;//output : 10.17   //convert decimal to currency. The currency format will depend on the region,   //like myself in malaysia compiler will automatically give "RM" as a currency format   string currency = String.Format("Order Total: {0:C}", price); //output :RM10.17   currency = String.Format("Order Total: {0:C2}", price); //output :RM10.17 ,2 decimal poi

How to send email in ASP.NET- C# example

Image
This is example how to send email from asp,net web application. Refer this post if you want to send email in java code . This example will use google smtp email server. The aspx Page <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">     <asp:Label ID="LErrorMessage" runat="server" ></asp:Label>     <asp:Button ID="Button1" runat="server" Text="Send Email" OnClick="Button1_Click" /> </asp:Content> The Code Behind  protected void Page_Load(object sender, EventArgs e)         {         }         protected void Button1_Click(object sender, EventArgs e)         {                        string emailContent = "This mail is created and send through the c# code,"                     + "\n\n if you are developers, visit http://www.developersnote.com!",                     subject = "Developersnote update - Mail Send Using AS

How to send email in java - example

Image
This is a example code to send email in java. This example will use 3rd party library JavaMail   . The Code Example import java.util.Properties; import javax.mail.Message; import javax.mail.MessagingException; import javax.mail.PasswordAuthentication; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; /**  *  * @author zulkamal  */ public class sendEmail {     public static void main(String[] args) {         final String username = "yourgmailaddress@gmail.com";         final String password = "your password gmail";         Properties props = new Properties();         props.put("mail.smtp.auth", "true");         props.put("mail.smtp.starttls.enable", "true");         props.put("mail.smtp.host", "smtp.gmail.com");         props.put("mail.smtp.port", "587");         Session session = Session.getInstance

How to create XML File In Java

This is a example of creating XML file in java application. The Main Class Code import java.io.File; import java.util.ArrayList; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import org.w3c.dom.Attr; import org.w3c.dom.Document; import org.w3c.dom.Element; public class CreateXml {     public static void main(String[] args) throws TransformerException {         ArrayList<String> arrayOne = new ArrayList<String>();         ArrayList<String> arrayTwo = new ArrayList<String>();         ArrayList<String> arrayThree = new ArrayList<String>();                 for(int i = 0; i

Jquery - Basic function for beginner

This is a jQuery basic fucntion that developers need to know. Do something after page load successfully $(document).ready(function() {   //do something }); Select Element by id / class var element = $("#idOfElement"); var elementByClass = $(".className"); if have more than one element with same class name var elementByClass = $(".className")[0]; Get selected value (drop down) var selectedValue = $("#isDropdown").val(); //return selected value Or var selectedValue = $("#isDropdown option:selected").val(); //return selected value Get selected text(drop down) var selectedValue = $("#isDropdown").text(); //return selected text Or var selectedValue = $("#isDropdown option:selected").text(); //return selected text Get Textbox Value var valueTextBox = $("#idTextbox).val();   Show/hide element  $("#idElement).show(); or  $("#idElement).fadeIn(500);  $("#idElement).hide(); or  $("#idElement).fadeOut(5

[SOLVED] JQuery - AJAX 500 Internal Server Error - JSON - jQueryAjax

Image
The above error always occur if you work with jQuery + Ajax. The error above may have several reason why the error occur and one of the reason is you are using the different parameter name to post to the server. Let say the method getState in webservice require one parameter which will represent country name, you must use the exactly name parameter to request from webservice. The Other Reason Not using JSON.stringify to pass parameter value. If you not supply type in jQuery, it will use GET method which is not accept in your webservice configuration. Add  ( type : "POST ) in your jQuery code to use POST method. You are actually request data from different domain. Cross Domain Request (CORS)which is not allowed. Please read here Content type not supply or not correct. Use " application/json; charset=utf-8 " DataType not not supply or not correct. Use json or jsonp By Mohd Zulkamal NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Fa