Posts

LINQ Basic

LINQ BASIC I am starting from this mail to show the technical skills to work with LINQ . The following is a very basic LINQ Query Expression Example: string[] strCities = { "Mumbai", "Delhi", "Surat", "Chennai", "Ahemdabad", "Jaipur" }; IEnumerable strResult = from city in strCities select city.ToUpper(); grdLinqBasic.DataSource = strResult; grdLinqBasic.DataBind(); In the above Example I am using the array of string and then using LINQ query expression against the array. I am also applying a string operation in the query itself, which help us to modify the result in the query itself. LINQ queries return results of type: IEnumerable Where is determined by the object type of the “select” clause of the query. In the above sample “city” is string. So the above example have the IEnumerable type is “string”. LINQ is STORNGLY-TYPED It means we can have compile-time c...

To provide file download Facility in ASP.Net

Image
To provide file download facility to use in from the website the following code need to be done in the button click event protected void Button1_Click(object sender, EventArgs e) { string path = Server.MapPath("html-character-entities-cheat-sheet.pdf"); string name = System.IO.Path.GetFileName(path); Response.AppendHeader("content-disposition","attachment; filename=" + name); Response.ContentType = "Application/pdf"; Response.WriteFile(path); Response.End(); }

To Avoid Popup Blocker to open Pop up from website.

The Following code will used to open popup window and the popup blocker will not block it. Code Of The Parent Page of Popup <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPopupBlocker.aspx.cs" Inherits="TestPopupBlocker" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" &gt ; <html xmlns=" http://www.w3.org/1999/xhtml " > <head runat="server"> <title>Untitled Page</title> <script language ="javascript"> function getAjaxXml() { var xml; if(document.all) { //IE xml = new ActiveXObject("Microsoft.XMLHTTP"); } else { //FF,Opera,NN ...

Chanakya's Quotes - Worth reading a million times…

Chanakya's Quotes - Worth reading a million times… *************************************************** 'A person should not be too honest. Straight trees are cut first and Honest people are victimised first.' *************************************************** 'Even if a snake is not poisonous, it should pretend to be venomous.' *************************************************** 'The biggest guru-mantra is: Never share your secrets with anybody. ! It will destroy you.' *************************************************** 'There is some self-interest behind every friendship. There is no Friendship without self-interests. This is a bitter truth.' *************************************************** 'Before you start some work, always ask yourself three questions - Why am I doing it, What the results might be and Will I be successful. Only when you think deeply and find satisfactory answers to these questions, go ahead.' ****************...

Anger & Love

ANGER & LOVE While Dad was polishing his new car, his four-year old son picked up a stone & scratched lines on the side of the car. In his anger, Dad took the child's hand & hit it many times, not realizing he was using a wrench. At the hospital, his child said, "Dad, when will my fingers grow back?" Dad was so hurt, he went back to the car and kicked it a lot of times. Sitting aside, he looked at the scratches. Child wrote, "I LOVE YOU DAD". ANGER & LOVE have no limits..... we never realize when we hurt someone..... its easy hurting..... n its easy forgiving but its very hard to forget..... specially for the one who's hurt..... Whenever you are angry remember this story...

Error Logging using ASP.NET 2.0

Error Logging using ASP.NET 2.0 This article has been republished with a few minor changes. Errors and failures may occur during development and operation of a website. ASP.NET 2.0 provides tracing, instrumentation and error handling mechanisms to detect and fix issues in an application. In this article, we will adopt a simple mechanism to log errors and exceptions in our website. We will be using a mechanism where the user will be redirected to a separate page whenever an error is encountered in the application. Simultaneously, the error will get logged in a text file on the server. The error file will be created on a daily basis, whenever the error is encountered. Having said that, let us now see some code. Step 1: Start by creating an Error folder where all errors will be logged. Right click the website > New Folder. Rename the folder to “Error”. Also add a web.config file, if one does not already exist in your site. Right click the website > Add New Item > Web.config. Step...

Using Session State with SQL Server

SQL Server Session State in ASP.NET 2.0 The Following Command is used to install Sql Server Session state for ASP.NET 2.0 c:\Program Files\Microsoft Visual Studio 8\VC>aspnet_regsql.exe -C "Data Source=PC8\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True" -ssadd -sstype c Start adding session state. .......... Finished. To use this custom session state database in your web application, please specify it in the configuration file by using the 'allowCustomSqlDatabase' and 'sqlConnectionString' attributes in the \ section. c:\Program Files\Microsoft Visual Studio 8\VC> The Following statement is needed to add in WEb.config File < system.web > < sessionstate allowcustomsqldatabase="true" timeout="20" mode="SQLServer" cookieless="false" sqlconnectionstring="Data Source=PC8\SQLEXPRESS;Initial Catalog=AdventureWorks;Integrated Security=True" > < /sessionstate > < /SYSTEM.W...