Multi Language Site Creation Using MVC C# , ASP.NET Using Visual Studio 2013 – Kannada / Arabic / English

Scenario : You want to create an web application which supports multi language. Your site may contain models , form labels, hyper links which needs to be in the required language. We can also have a language switcher. Solution : Use Resource .resx xml file. Tools Required : Visual Studio 2013 Features: Extend as many number of Languages you want Form can be created with different language labels Link labels can be changed language switch option Easily editable Resource Files Create New Project Select Web ==> Asp.net MVC4 Web Application ==> Project Name :: Haneef Select Internet Application Right Click Project Name ==> Add New Folder ==> Name it as Resources Right Click Resources Folder which we created ==> Add New Item Select General Tab from left Hand Side  and Select Resources File from Right Side Name the new file as  LangText.Resx Now Enter the string Name and Value as shown below, Click Access Modifier as Public, Then Click Save All as shown Now Right Click LangText.Resx ==> Copy Paste to Same Folder Now Rename the Pasted File as LangText.Ar.Resx Now Edit the Content of Resx file to include Arabic Translations and Save. Now Again make a copy for Kannada […]

» Read more

Installing Oracle ODBC Driver to Windows 2012 Server R2

Step1:   Download 32-bit Oracle Data Access Components (ODAC) with Oracle Developer Tools for Visual Studio http://www.oracle.com/technetwork/topics/dotnet/utilsoft-086879.html   After installing the above software create a envirnoment variable called TNS_ADMIN Variable Name :TNS_ADMIN Variable Value : C:\oracle\product\10.2.0\client_2\network\admin  (Make sure path is correct. If your machine is connected to Domain path may differ) Step3: Open C:\Windows\SysWOW64\odbcad32.exe USER DSN –> Add –> Oracle in Ora Clientxxx If you cannot see the TNS service name in drop down means you have not done previous step. You can also check the proper settings by pressing Test Connection and providing the Credentials.    .

» Read more

PL/SQL for Sending Email with Mandrill API :: Oracle UTL_SMTP with Authentication

CREATE OR REPLACE PR OCEDURE p_send_mail ( p_sender_name IN VARCHAR2, p_sender IN VARCHAR2, p_recipient IN VARCHAR2, p_subject IN VARCHAR2, –p_cc IN VARCHAR2, p_message IN VARCHAR2) IS conn UTL_SMTP.CONNECTION; crlf VARCHAR2(2) := CHR(13) || CHR(10); — Mandrill Login Details uname VARCHAR2(200) := ‘mandrillusername@yourdomain.com’; EmailServer VARCHAR2(60) := ‘smtp.mandrillapp.com’; pwd VARCHAR2(200) := ‘mandrillappkey’; p_port VARCHAR2(10) := ’25’; — if you have issue use port 587 pq_message VARCHAR2(5000); — Do Not Edit Below This Line — This PL/SQL procedure is created and tested by Haneef Puttur , for Mandrill BEGIN conn := utl_smtp.open_connection(EmailServer, p_port); utl_smtp.ehlo(conn, EmailServer); utl_smtp.command(conn, ‘AUTH LOGIN’); utl_smtp.command(conn, utl_raw.cast_to_varchar2(utl_encode.base64_encode( utl_raw.cast_to_raw(uname)))); utl_smtp.command(conn, utl_raw.cast_to_varchar2(utl_encode.base64_encode( utl_raw.cast_to_raw(pwd)))); utl_smtp.mail(conn, p_sender); utl_smtp.rcpt(conn, p_recipient); pq_message:= ‘Date: ‘|| TO_CHAR(SYSDATE, ‘DD MON RR HH24:MI:SS’ )|| crlf || ‘From: “‘ || p_sender_name || ‘” ‘ || p_sender || crlf || ‘Subject: ‘ || p_subject || crlf || — ‘Cc: ‘ || p_cc || crlf || — uncomment this line for sending cc ‘Content-Type: text/html;’ ||crlf || — Comment this line if you want only plain text email ‘To: ‘|| p_recipient || crlf|| p_message || crlf || crlf; utl_smtp.data(conn, pq_message); utl_smtp.quit(conn); EXCEPTION WHEN OTHERS THEN RAISE_APPLICATION_ERROR(-20001,SQLERRM); END ; To Test This Procedure: EXEC .p_send_mail(‘Haneef Puttur’,’yourname@youremail.com’,’toaddress@test.com’,’Message Subject’,’Haneef Puttur, This is test messgae.<br> I am […]

» Read more

ASP.net MVC Creating SEO friendly URL (Routing)

I want to pass 2 parameters to my controller and wants to display it int the razor view . Task :  Change URL From : http://localhost:50842/Contracts/Index?first=Line1&second=Line2 To       :  http://localhost:50842/Contracts/Index/Line1/Line2 My Controller: My View : My Classic method is : Pass the URL as query string : http://localhost:50842/Contracts/Index?first=Line1&second=Line2 Here I am passing the parameters as above. and the controller will translate in the controller. This request is handled by default route config file available at the visual studio mvc. This is my current route file   If i run the project,  with above parameters my output will be as follows. Now my task is i want to convert the URL into much user friendly as follows. http://localhost:50842/Contracts/Index/Line1/Line2 This is simple and parameter names to be assigned by the route config. To achieve this , i need to edit my route config fie as follows. As you can see i have hard coded the parameter names in route file so that the moment i call the url , it will translate and assign as parameter names based on the positions. If you run the project after making changes you will see the out put as follows.   By adding a simple […]

» Read more

ASP.NET MVC Razor Sample HTML Helper Creation

Simplest example of creating an HTML helper method in Asp.net MVC Razor View In this example I am creating an helper method to format the currency cuurency color to be red if value is minus and green if value is positive. Step 1 : Create the helper function Step 2 : Create an decimal array Step 3. Run a loop to get each value of decimal array and call the helper method to format the view. This is a sample example and can be extended to achieve other goals.   @{ var amounts = new List<Decimal> { 12.34m, 12.45m, -12,-19,32.5m,123, 234, -56 }; } <ul> @foreach (Decimal amount in amounts ) { <li> @FormatAmount(amount)</li> } </ul> @helper FormatAmount(decimal amount) { var color = “green”; if (amount < 0 ) { color = “red”; } <span style=”color:@color”>Pending Amount Is : @String.Format(“{0:c}”, amount) </span> } Output .

» Read more
1 2