Posts

Showing posts from November, 2015

Differance between var and dynamic in c#

The below differance are very usefull and cachhe words..... var dynamic Introduced in  C# 3.0 Introduced in  C# 4.0 Statically typed  – This means the type of variable declared is decided by the compiler at compile time. Dynamically typed  - This means the type of variable declared is decided by the compiler at runtime time. Need  to initialize at the time of declaration. e.g.,  var str=”I am a string”; Looking at the value assigned to the variable  str , the compiler will treat the variable  str  as string. No   need  to initialize at the time of declaration. e.g.,  dynamic str; str=”I am a string”;  //Works fine and compiles str=2;  //Works fine and compiles Errors are caught at compile time. Since the compiler knows about the type and the methods and properties of the type at the compile time itself Errors are caught at runtime Since the compiler comes to about the type and the methods and properties ...

Uses of all page notations in .Net like ASPX,ASMX,ASAX .................... in asp.net

.asax : Global.asax, used for application-level logic .ascx :  Web UserControls: custom controls to be placed onto web pages. .ashx :  custom HTTP handlers. .asmx :  web service pages. From version 2.0 a Code behind page of an asmx file is placed into the app_code folder. .axd :  when enabled in web.config requesting trace.axd outputs application-level tracing. Also used for the special webresource.axd handler which allows control/component developers to package a component/control complete with images, script, css etc. for deployment in a single file (an 'assembly') .config :  web.config is the only file in a specific Web application to use this extension by default (machine.config similarly affects the entire Web server and all applications on it), however ASP.NET provides facilities to create and consume other config files. These are stored in XML format. .cs/vb :  Code files (cs indicates C#, vb indicates Visual Basic). Code behind files (see a...

j query validation with textboxs in asp.net

$(document).ready(function() { $('# btnSubmit ').click(function(e) { //btnSubmit is button id  //For all text boxes  "text" var isValid = true; $('input[type= "text" ]').each(function() { if ($.trim($(this).val()) == '') { isValid = false; $(this).css({ "border": "1px solid red", "background": "#FFCECE" }); } else { $(this).css({ "border": "", "background": "" }); } }); if (isValid == false) e.preventDefault(); else alert('Thank you for submitting'); }); //for all validations are completed or not condition isvalid });​

Get files from folder with out specifing folder path using c#

var filenames3 = Directory . GetFiles ( dirPath , "*" , SearchOption . AllDirectories ) . Select ( f => Path . GetFileName ( f ));  filenames only var filenames4 = Directory . EnumerateFiles ( dirPath , "*" , SearchOption . AllDirectories ) . Select ( Path . GetFileName ); // <-- note you can shorten the lambda file names and directory path..... // - file1.txt // - file2.txt // - subfolder1/file3.txt // - subfolder2/file4.txt var skipDirectory = dirPath . Length ; // because we don't want it to be prefixed by a slash // if dirPath like "C:\MyFolder", rather than "C:\MyFolder\" if (! dirPath . EndsWith ( "" + Path . DirectorySeparatorChar )) skipDirectory ++; var filenames4s = Directory . EnumerateFiles ( dirPath , "*" , SearchOption . AllDirectories ) . Select ( f => f . Substr...

Ftp transfer files from local to remote ftp server using c#

Image
  public bool testConnection()         {             string strFTPServer = string.Empty;             string strUserName = string.Empty;             string strPassword = string.Empty;             string testconnection = string.Empty;                            WebRequest request = WebRequest.Create("ftp://" + strFTPServer);             request.Method = WebRequestMethods.Ftp. ListDirectoryDetails;             request.Credentials = new NetworkCredential(strUserName, strPassword);             try             {                 using (var resp = (FtpWebResponse)request. GetResponse())     ...

How to display json data in console application in c#

Program.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web.Script.Serialization; using System.IO; namespace ConsoleApplication1 {     class Program     {         static void Main(string[] args)         {             JavaScriptSerializer obj = new JavaScriptSerializer();             string str = File.ReadAllText("json.json");                 Employee oblemp=obj.Deserialize<Employee>(str);                 Console.WriteLine("Employee Number = "+oblemp.ID +" Employee Name ="+oblemp.Name);                 Console.ReadLine();         }     }     public class Employee     {         public string Name { ...

CRUD Operation Entity Framework using asp.net MVC

=> Add Ado.Net Entity Data model template => Choose data base required data => Add Add controller => HomeController.cs .............................................. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using MvcApplication1.Models; using System.Data; namespace MvcApplication1.Controllers {     public class HomeController : Controller     {         UniversalEntities db = new UniversalEntities();         public ActionResult Index()         {            List<tvl_Country> obj= db.tvl_Country.ToList();            return View(obj);         }         public ActionResult Create()         {             return View();         } ...

any Data type to string

int i=10; 1...  string r = i.tostring(); 2....  string se = (string)i; 3.........   string ses = convert.tostring(i); in the above like object                            double                           float                           char                          long                          small                          date time

Generate Exe File with user specific path dialogs in windows application c#

Image
=> first u can install these template from microsoft free ware     ::::>>>                               installshield limited edition for visual studio 2013