Tuesday, October 31, 2006

Removing Duplicates Item from DropDownList

public static void RemoveDuplicateItems(DropDownList ddl)

for (int i = 0; i < ddl.Items.Count; i++)
ddl.SelectedIndex = i;
string str = ddl.SelectedItem.ToString();
for (int counter = i + 1; counter < ddl.Items.Count; counter++)
ddl.SelectedIndex = counter;
string compareStr = ddl.SelectedItem.ToString();
if (str == compareStr)
counter = counter - 1;

How to set hyperlinkfield to make it point to local file?

In Web.Config File

appSettings --Begin
add key="AboutTess_Pdf_Path" value="Documents/sampleAboutTess.pdf"
appSettings --End

In .CS File

string strPDFPath = ConfigurationSettings.AppSettings["AboutTess_Pdf_Path"].ToString();

string popupScript = "Javascript: return " +
"window.open('"+ strPDFPath + "', 'CustomPopUp', " +
"'width=600, height=600, menubar=no, resizable=yes');";

//Attach Script to button control

Sunday, October 29, 2006

Merge Individual Query Result in a sorted fashion

It is not possible to apply Order by Clause while using UNION Query, when we want to sort the individual query result and then want to merge the result data

Case: If we want to sort the individual query result and then want to merge the result data it is not possible to do so. Read the following article to see how it is possible.


select categoryid,categoryname
from categories
order by 2
select productid,productname
from products
order by 2

--It will give me following error
Server: Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'UNION'.

Partial Solution
select categoryid,categoryname
from categories
select productid,productname
from products
order by 2

--Problem with Partial Solution
It will sort all the result data by column 2., It is general sorting which is applied when we want to sort all the result data.

But what if we want to sort the individual query result and then want to merge the result data.


select * from
select categoryid,categoryname, 1 as myOrder
from categories
select productid,productname, 2 as myOrder
from products
order by myTable.myOrder

So finally here the result query will display the data sorted by category and then by product. and the result data is shown.

Sending Web Page as Email

Take 4 Textbox control
1 - For URL typing (URL of webpage you want to send as a mail).
2 - For To Field (Email address of user sending the page.)
3 - For From Field (Destination Email address you want to send).
4 - For Subject Line

Now, switch to code view and add following namespace.

using System.IO;
using System.Net;
using System.Web.Mail;

//Function which convert URL information as string
//Which is used latter to passed as body message.
private String readHtmlPage(string url)
String result;
WebResponse objResponse;
WebRequest objRequest = System.Net.HttpWebRequest.Create(url);
objResponse = objRequest.GetResponse();
using (StreamReader sr =
new StreamReader(objResponse.GetResponseStream()) )
result = sr.ReadToEnd();
// Close and clean up the StreamReader
return result;

//Code for sending webpage as email.
private void btnSend_Click(object sender, System.EventArgs e)
//URL is converted into string message.
String message=readHtmlPage(txtURL.Text);
String mailServer = ""; //Change with your mail server address.

MailMessage Mailer = new MailMessage();
Mailer.From = txtFrom.Text;
Mailer.To = txtTo.Text;
Mailer.Subject = txtSubject.Text;
Mailer.Body = message;
Mailer.BodyFormat = System.Web.Mail.MailFormat.Html;
lblResult.Text = "Page successfully sent!";
catch(Exception ex)
lblResult.Text = "An error occurred: " + ex.ToString();


Friday, October 27, 2006

Microsoft Preps XP-to-Vista App Migration Tool

Microsoft will unveil a tool to help Windows XP users migrate not only files and settings, but also applications to Windows Vista when the operating system launches, a company worker said.

Microsoft has released several tools to assist migration to Windows Vista, including an application compatibility kit that identifies applications that will run on Vista and tags those that need further testing or modification.

Read the whole story

Visual Studio Add-Ins : Essential Tools

Essential Tools, Visual Studio Add-Ins Every Developer Should Download Now

  1. TestDriven.NET
  2. GhostDoc
  3. Smart Paster
  4. CodeKeep
  5. PInvoke.NET
  6. VSWindowManager PowerToy
  7. WSContractFirst
  8. VSMouseBindings
  9. CopySourceAsHTML
  10. Cache Visualizer
  11. Wrapping It Up
Get the article at the link below:
Visual Studio Add-Ins Every Developer Should Download Now

Google offers personal searches

Google Custom Search Engine, as the tool is known, allows users to choose which webpages to search. Users can also customise the look of results, how web content is prioritised or add paying adverts to the results. For more detail click here

Thursday, October 26, 2006

Microsoft Blogstar Contest

Microsoft has announced the Microsoft Blogstar Contest a contest to identify the best Developer bloggers in India.

For registration and more information, check Microsoft Blogstar Contest

IndiMix 2006

IndiMix is the Indian version of MIX 2006 but has great additional flavours. One of the key things is that, Steve Ballmer, CEO, Microsoft Corporation addresses the key note and this is exclusively for this Indian event.

Venue: National Centre for the Performing Arts,Nariman Point,Mumbai 400 021India.

You can register for the Event online at IndiMix Event Registration

In case you feel you cannot make it for the event, in-person, then there is a Live Webcast, for which you can register at IndiMix Webcast Registration

Consuming RSS Feed is easy with RSS Toolkit

Consuming RSS Feed is easy with RSS Toolkit

check out the following link : http://blogs.msdn.com/dmitryr/archive/2006/02/21/536552.aspx

The RSS toolkit includes support for consuming as well as publishing RSS feeds in ASP.NET applications.

To know more about RSS Toolkit and downloading the component logon to http://blogs.msdn.com/dmitryr/archive/2006/02/21/536552.aspx

Windows Defender

Windows Defender is a free program that helps you stay productive by protecting your computer against pop-ups, slow performance and security threats caused by spyware and other potentially unwanted software. Download it

Powerful web browser : Maxthon

Maxthon is a powerful web browser with a highly customizable interface. It is based on the Internet Explorer engine which means that what works in IE, works the same in Maxthon but with many additional efficient features. Download It

Wednesday, October 25, 2006

ASP.NET AJAX Beta 1 Released

From Scott Guthrie's Blog:

Today I am very pleased to announce the first official Beta release of Microsoft ASP.NET AJAX v1.0. You can download it now from the http://ajax.asp.net site. Available on the site are three download options:

1) The ASP.NET AJAX v1.0 “Core” download. This redist contains the features that will be fully supported by Microsoft Product Support, and which will have a standard 10 year Microsoft support license (24 hours a day, 7 days a week, 365 days a year). The download includes support for the core AJAX type-system, networking stack, component model, extender base classes, and the server-side functionality to integrate within ASP.NET (including the super-popular ScriptManager, UpdatePanel, and Timer controls).

2) The ASP.NET AJAX “Value-Add” CTP download. This redist contains the additional higher-level features that were in previous CTPs of “Atlas,” but which won’t be in the fully-supported 1.0 “core” redist. These features will continue to be community supported as we refine them further and incorporate more feedback. Over time we’ll continue to move features into the “core” download as we finalize features in this value-add package more.

3) The ASP.NET AJAX Control Toolkit. This project contains 28 free, really cool, AJAX-enabled controls that are built on top of the ASP.NET AJAX 1.0 “Core” download. The project is collaborative shared source and built by a combination of Microsoft and non-Microsoft developers, and you can join the community or just download it on CodePlex today.

SQL Refactor from Red Gate

This software does what it's name implies. It helps you to refactor your database and SQL code. http://www.red-gate.com/messageboard/viewtopic.php?t=3438

For SQL Prompt: http://www.red-gate.com/products/SQL_Prompt/index.htm?gclid=CLaPur_8gogCFQt7WAodtxE5tw

Tuesday, October 24, 2006

Add-ons for IE7

Download add-ons for IE7 from www.ieaddons.com

IE7 Now Available

IE7 Now Available

It beats Firefox 2 out the door. Barely. Download it from http://www.microsoft.com/windows/ie/downloads/default.mspx

This is a major improvement over IE6, both in features (tabs, finally!) and in security. It's still a step behind Firefox in my opinion, but has significantly narrowed the gap.

Monday, October 23, 2006

Tips and Tricks for coding

I enjoyed reading Tips and Tricks from ScottGu's Blog, it is really interesting.  Try to find out more detail from his blog.
Tip/Trick: Using Server Side Comments with ASP.NET 2.0 

You are coding away on an ASP.NET page, and are trying to isolate a problem within the page. You have some existing html/controls/markup/in-line code that is being used on the page, and you want to temporarily comment it out while you fix the problem.
ASP.NET supports a little known feature called “server-side comments” that you can use to completely disable code/controls/html in a page. Server-side comments in ASP.NET are delimited using a <%-- --%> syntax.

For more info for this tip : http://weblogs.asp.net/scottgu/archive/2006/07/09/Tip_2F00_Trick_3A00_-Using-Server-Side-Comments-with-ASP.NET-2.0-.aspx
For more Information on lots of coding tricks log to ScottGu's Blog : http://weblogs.asp.net/scottgu/pages/ASP.NET-2.0-Tips_2C00_-Tricks_2C00_-Recipes-and-Gotchas.aspx

Sunday, October 22, 2006

Happy Diwali

Wishing you a very Happy Diwali.May this Diwali brings lots of happienss

Sunday, October 15, 2006

.Net FAQs Links

Dot Net FAQs
1) http://www.dailyfreecode.com/


ASP.net FAQs
1) http://www.syncfusion.com/faq/aspnet/default.aspx
2) http://www.aspnetfaq.com
3) http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=4081&lngWId=10
4) http://blogs.crsw.com/mark/articles/254.aspx
5) http://www.techinterviews.com/?p=176 & http://www.techinterviews.com/?p=193
6) http://www.eggheadcafe.com/articles/20021016.asp
7) http://www.cmap-online.org/Default.aspx?tabindex=4&tabid=-17

1) http://www.andymcm.com => for c# and dot net frame work faqs
2) http://www.syncfusion.com/faq/windowsforms/default.aspx
3) http://www.c-sharpcorner.com/faq.asp
4) http://msdn.microsoft.com/vcsharp/productinfo/faq/default.aspx
5) http://www.yoda.arachsys.com/csharp/faq/
6) http://www.gotdotnet.com/team/csharp/learn/faq/
7) http://www.syncfusion.com/faq/windowsforms/default.aspx

Saturday, October 14, 2006

Import Excel To Datagrid ASP.net

private void btnImportExcelToGrid_Click(object sender,
System.EventArgs e)
String strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=C:\\Book2.xls;" +
"Extended Properties=Excel 8.0;";

DataSet ds = new DataSet();
//You must use the $ after the object
//you reference in the spreadsheet
OleDbDataAdapter da = new OleDbDataAdapter
("SELECT * FROM [Sheet1$]", strConn);

//da.TableMappings.Add("Table", "ExcelTest");

DataGrid2.DataSource = ds.Tables[0].DefaultView;

Note: If you want to give client upload facility, than first upload the file to the server. Next call the excel file from the following server location. Reference: http://www.dotnetspider.com/kb/Article361.aspx

Export Datagrid Data To Excel ASP.net

private void btnExportToExcel_Click(object sender,
System.EventArgs e)

private void ExportToExcel(string strFileName,DataGrid dg)
{ Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
"attachment;filename=" + strFileName);
Response.Charset = "";
this.EnableViewState = false;
System.IO.StringWriter sw = new StringWriter();
System.Web.UI.HtmlTextWriter htw = new HtmlTextWriter(sw);

Google Code Search

There is yet another brand new service from Google named as Google Code Search. This service designed to make it easier for computer programmers to find bits of code online. Google Code Search will make it easier for software developers to find programming code directly, without having to search forums, most of which are open source code.


Friday, October 13, 2006

Brainbench Certified for .Net Framework Fundamental

I have achieved .NET Framework Fundamentals Certificate of Brainbench. You can logged to http://www.brainbench.com/ and enter my transcript-id : 6274829


Friday, October 06, 2006

Generating Registration Image on FLY in asp.net

This article focus on generating image on fly in asp.net. This is very basic functionality which you find on almost all the website which require registration of user. Example: Yahoo Registration require to type you secret string before you can successfully login, this feature has no. of reasons and i am not going into detail of why we want rather i am explaining here how we can. Look for Screenshot for better idea

For demo purpose i am generating image on button click. But generally you require to generate image on page load event of registration form.
Ok back on coding.
Step1: Create a new web application
Step2: Open Code Behind Form of web application you have created.
Step3: Add Namespace for drawing Image.
using System.Drawing;
using System.Drawing.Imaging;
Step4: Write Code for Generating Random Registration String (Here: Generating Random string of 10 in length).
// Generate a random password with the specified length. The password will only
// contain digits and letters (either lowercase or uppercase)
public static string GetRandomPassword(int length)
Random rand = new Random();
System.Text.StringBuilder password = new System.Text.StringBuilder(length);
for (int i = 1; i <= length; i++) { int charIndex; // allow only digits and letters do { charIndex = rand.Next(48, 123); } while (!((charIndex >= 48 &&amp;amp; charIndex <= 57) (charIndex >= 65 && charIndex <= 90) (charIndex >= 97 && charIndex <= 122))); // add the random char to the password being built password.Append(Convert.ToChar(charIndex)); } return password.ToString(); }

Step5: Write Code for Generating Image. This code will create RegistrationImg.gif in your application folder.
//Generate Image
private void GenerateImage(string strRegistrationStr)
Bitmap objBitmap = new Bitmap(150, 30);
Graphics objGraphics = Graphics.FromImage(objBitmap);

//Fore Color and Background of Image
SolidBrush objForeColor = new SolidBrush(Color.White);
SolidBrush objBackColor = new SolidBrush(Color.Black);

objGraphics.FillRectangle(objBackColor, 0, 0, 150, 30);
//Font settings for Image
Font objFont = new Font("Arial", 15);
//Display from 5point from x-axis and 5point from y-axis
Point objPoint = new Point(5, 5);
//Drawing Registration String
objGraphics.DrawString(strRegistrationStr, objFont, objForeColor, objPoint);
//Saving Registration String as Image
//If you dont want image to save
//objBitmap.Save(Response.OutputStream, ImageFormat.Gif);
//otherwise use this
objBitmap.Save(Server.MapPath("RegistrationImg.gif"), ImageFormat.Gif);
//Release object
if(objBitmap != null)
if (objGraphics != null)

Step6: Finally code for calling the created functionality.
protected void btnShowRegistrationImg_Click(object sender, EventArgs e)
ImgRegistrationStr.ImageUrl = "RegistrationImg.gif";

Wednesday, October 04, 2006

Won a Grand Prize @ Community-Credit

Hello Friends,

Again Won a Grand Prize @ Community-Credit

check out url and select "August 2006" from drop-down : http://www.community-credit.com/DisplayCommunityCreditPerMonth.aspx

I have won : Optimus Mini Three Keyboard

The Optimus Mini connects to your PC via USB and features three keys, each with their own backlit OLED screen. Each key can display a static image or full animation. Press the key and a different action occurs depending on what is assigned to it. Think it as some kind of futuristic dynamic hotkey device.
The bundled Optimus Mini Configurator software allows you to assign various actions to each of the three keys. Furthermore you can instantly switch between six different key layouts by holding down the Ctrl, Shift, Alt-Shift, or Ctrl+Shift keys on your larger keyboard. Hotkey options for Internet Explorer, Microsoft Word, Outlook Express and Windows media player are included. But forget about the practical stuff... what we liked best was being able to assign a different webcam image to each key and have them dynamically update. Or have a clock face with animated second hand displaying the time in Tokyo on one key while a CPU Usage graph scrolled across another key. You can of course mix and match the key functions to your desire and there is even support for portrait or landscape orientation.

Visual Studio and Vista Conflicts

Microsoft Cautions Developers About Visual Studio/Vista Conflicts Microsoft set off a furor among developers this week when it disclosed that Visual Studio 2005 won't be fully compatible with Vista and that older versions of Visual Studio won't be supported at all on Vista. Microsoft pledged to smooth out the Visual Studio 2005 software conflicts with a patch "soon" after Vista's release. Stacy Cowley

The bad thing is Visual Studio 2003's users cann't write applications in Vista , it means there are forced to migrate to 2005 version and also orcas is in the way. BTW Sql Server 2005 is also need a patch to work without any conflict in Vista. If it means Sql Server 2000 doesn't work in Vista ?

Monday, October 02, 2006

ASP.net Website Paths

Determining Physical Path of an Application

The MapPath method returns the complete physical path for a virtual path that you pass to the method. For example, the following code returns the file path for the root of your Web site:
String rootPath = Server.MapPath("~");

Client Elements
Elements that are not Web server controls on a page—client elements—are passed through as-is to the browser. Therefore, when referring to a resource from a client element, you construct paths according to standard rules for URLs in HTML. You can use a fully qualified (which is also known as absolute) URL path or various types of relative paths. For example, if your page contains an img element, you can set its src attribute using one of the following paths:

1) An absolute URL path. An absolute URL path is useful if you are referencing resources in another location, such as an external Web site.
img src="http://www.yahoo.com/MyApplication/Images/SampleImage.jpg"

2) A site-root relative path, which is resolved against the site root (not the application root). Site-root relative paths are useful if you keep cross-application resources, such as images or client script files, in a folder that is located under the Web site root.

This example path assumes that an Images folder is located under the Web site root.
img src="/Images/SampleImage.jpg"

Here, If your Web site is http://www.yahoo.com, the path would resolve to the following.

3) A relative path that is resolved against the current page path.
img src="Images/SampleImage.jpg"

4) A relative path that is resolved as a peer of the current page path.
img src="../Images/SampleImage.jpg"

Server Controls

Absolute and relative path references in a server control have the following disadvantages:

i) Absolute paths are not portable between applications. If you move the application that the absolute path points to, the links will break.

ii) Relative paths in the style of client elements can be difficult to maintain if you move resources or pages to different folders.

To overcome these disadvantages, ASP.NET includes the Web application root operator (~), which you can use when specifying a path in server controls. ASP.NET resolves the ~ operator to the root of the current application. You can use the ~ operator in conjunction with folders to specify a path that is based on the current root.

The following example shows the ~ operator used to specify a root-relative path for an image when using the Image server control In this example, the image file is read from the Images folder that is located directly under the root of the Web application, regardless of where in the Web site the page is located.
asp:image runat="server" id="Image1" ImageUrl="~/Images/SampleImage.jpg"

Sunday, October 01, 2006

Microsoft .NET Framework 3.0 - Release

The Microsoft .NET Framework 3.0 (formerly known as WinFX), is the new
managed code programming model for Windows. It combines the power of the .NET
Framework 2.0 with new technologies for building applications that have visually
compelling user experiences, seamless communication across technology
boundaries, and the ability to support a wide range of business processes. These
new technologies are Windows Presentation Foundation, Windows Communication
Foundation, Windows Workflow Foundation, and Windows CardSpace (formerly code named "Infocard"). Microsoft plans to ship .NET Framework 3.0 as part of the
Windows Vista operating system. In addition, Microsoft is making these
technologies available on Windows XP and Windows Server 2003. The following
Community Technology Preview of .NET Framework 3.0 enables you to continue
experimenting with early builds of these technologies, get acquainted with the
development experience, and provide feedback to Microsoft.

Download : http://www.microsoft.com/downloads/details.aspx?FamilyId=19E21845-F5E3-4387-95FF-66788825C1AF&displaylang=en

Got in to All Time List of Community-Credits

I have been entered into All Time List of Community-Credit.

You can check out the Link : http://www.community-credit.com

Become a Most Valuable Member of DotNetSpider Team

I have started contributing on DotNetSpider last month.

And i become a Most Valuable Member of DotNetSpider Team.

Thanks God and my well wisher whose blessings works out for me.

You can check out : http://www.dotnetspider.com/team/SpiderTeam.aspx

Send Email from Gmail in asp.net 2.0

Simplest Way of Sending Email from Gmail

protected void btnSendEmail_Click(object sender, EventArgs e)
//Create Mail Message Object with content that you want to send with mail.
System.Net.Mail.MailMessage MyMailMessage = new System.Net.Mail.MailMessage("dotnetguts@gmail.com","myfriend@yahoo.com",
"This is the mail subject", "Just wanted to say Hello");

MyMailMessage.IsBodyHtml = false;

//Proper Authentication Details need to be passed when sending email from gmail
System.Net.NetworkCredential mailAuthentication = new
System.Net.NetworkCredential("dotnetguts@gmail.com", "myPassword");

//Smtp Mail server of Gmail is "smpt.gmail.com" and it uses port no. 587
//For different server like yahoo this details changes and you can
//get it from respective server.
System.Net.Mail.SmtpClient mailClient = new System.Net.Mail.SmtpClient("smtp.gmail.com",587);

//Enable SSL
mailClient.EnableSsl = true;

mailClient.UseDefaultCredentials = false;

mailClient.Credentials = mailAuthentication;


Most Recent Post

Subscribe Blog via Email

Enter your email address:

Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape