Wednesday, April 16, 2008

Various LInks

http://www.411asp.net http://www.aspnet.happycodings.com/index.html http://www.dreamincode.net http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&plcid=&pver=5.2&os=&over=&olcid=&clcid=&ar=Media&sba=Showcase&o1=&o2=&o3= http://www.codinghorror.com/blog/files/Visual%20Studio%20.NET%202005%20Keyboard%20Shortcuts.htm http://authors.aspalliance.com/aspxtreme/webforms/index.aspx http://www.w3schools.com/js/js_examples_3.asp http://www.dotnetbips.com/articles/e644e9a7-f1ec-41d1-ad19-5cda53b6e9cf.aspx http://aspnet.devdirect.com/All/PopupComponents_PCAT_2029.aspx http://aspalliance.com/1306_How_to_Show_MessengerLike_Popups_Using_AJAX.all http://swik.net/Ajax/del.icio.us%2Ftag%2Fajax/Developing+AJAX+based+popup+notifications/bk2c3 http://www.telerik.com/community/forums/allthreads/b312H-kh.aspx
Web Events
Visual Studio .NET 2005 Keyboard Shortcuts
ASPXtreme Web WorkShop: ASP.NET Web Forms
A workshop on .NET applications design and development. Step-by-step how-to pages help you learn skills and do specific tasks as you plan, build and manage your Web app, from start to finish.
JavaScript Examples
Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building.
DotNetBips.com :: Blossom your .NET skills
ASP.Net Popup Controls & Messenger Popup Components
Enable your applications to display Messenger-style popup windows to notify users of an event or request attention.
How to Show Messenger-Like Popups Using AJAX: ASP Alliance
In this article Bilal examines how to build a simple database notifier that pops a messenger-like popup on an ASP.NET page whenever a new record is inserted into the database table using ASP.NET 2.0 AJAX 1.0 Extensions.
Developing AJAX based popup notifications - SWiK
DotNetBips.com :: The .NET Knowledge Base - ASP.NET, C#, VB.NET, Web Services, Windows Forms and many mroe topics in .NET
Build ASP.NET, AJAX, and Windows Forms applications with confidence and ease
Telerik is a leading vendor of ASP.NET and Windows Forms UI components, Content Management Systems (CMS), Reporting solutions, and add-ons for SharePoint. Telerik's name is associated not only with reliable and high-performance products, but also with meticulous technical support.
DotNetBips.com :: Blossom your .NET skills
Yahoo! India News- Top 10 Hotels in India
Use Yahoo! India News to find breaking news, current events and the latest headlines and news photos & videos of top stories, world, business, entertainment, sports, technology, and more.
Calendar Sample
How to make a simple CSS dropdown menu | evolt.org
A world community for web developers, evolt.org promotes the mutual free exchange of ideas, skills and experiences.
Online Menu Design - Visual CSS QuickMenu
.NET Interview Questions at Microsoft .NET Support
What̢۪s a bubbled event? | walkin-interview.com
When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can
Kalptaru Infosoft Pvt Ltd - India - Other
Kalptaru Infosoft Pvt Ltd exports to North America, South America, Eastern Europe, Southeast Asia, Africa, Oceania, Mid East, Eastern Asia, Western Europe, with products under category and more.
Ahmedabad Software Companies - List of IT Companies in Ahmedabad, Gandhinagar
List of Software & IT Companies in Ahmedabad/Gandhinagar, Gujarat, India
Community : The Official Microsoft ASP.NET Site
Microsoft portal site for the ASP.NET development community. Download Visual Web Developer, post to the forums, read ASP.net blogs and learn about ASP.net.
Popup - Blog Toplist
Articles about Popup by blogs
JavaScript Regular Expressions patterns
Click here to learn about regular expressions in JavaScript
Dynamic Drive DHTML Scripts- Popup box
Controlling your Modem with AT Commands
Google
Software Engineering Proverbs
Stories about software engineering practices and lessons: Collected graffiti.
webpart 1
Microsoft ASP.NET QuickStarts Tutorial
.NET Framework Assemblies
Explains what are the .NET Framework assemblies and what are their benefits to make your programming tasks easier
TopSurveys
Make money from taking online surveys! You get paid for each survey, the longer the survey the more you get paid!
YouTube - Learn VB .NET - Custom Shaped Forms - VBdotNET.m-sn.com
http://vbdotnet.m-sn.com for 100s more video guides to vb.net
Walkthrough: Creating a Web Site with Membership and User Login
asp.net web templates
This site offers hundreds of website templates, free web templates, web templates, and free website templates for individuals, professionals and small business owners
Warez Releases - Full Warez Downloads Updated Every 5 Minutes!
RapidShare: 1-Click Webhosting

Difference b/w asp.net 2.0 and 3.5

asp.net 1.1 asp.net 2.0 (http://www.geekinterview.com/question_details/33965) • GridView control and the declarative data binding controls (the SqlDataSource, ObjectDataSource, and so on). • new data-bound UI controls such as GridView, DetailsView, FormView, TreeView, and Menu • Master Pages, Themes, Skins • Web Parts controls • Navigation Controls like Site Maps, Tree Views, Dynamic HTML Menus • Standard controls for security (Login, LoginStatus, LoginName, LoginView,CreateUser Wizard,PasswordRecovery) • Roles and Personalization • PreCompilation • Sharing code in the application asp.net 3.0 • Inbuilt ajax support • LINQ (Language-Integrated Query) • A new ListView data control that displays data and that provides a highly customizable UI. • The DataPager control • A new LinqDataSource control that exposes Language-Integrated Query (LINQ) through the ASP.NET data source control architecture. • A new merge tool (Aspnet_merge.exe) that merges precompiled assemblies to support flexible deployment and release management. • Multi-targeting Web Applications • JavaScript debugging and IntelliSense features

Read a file

Read a file <%@ Import Namespace="System.IO" %>

Checks whether Javascript is supported/enabled

Checks whether Javascript is supported/enabled If Request.Browser.JavaScript = True Then Response.Write("JavaScript supported/enabled ") End If

raise events from a user control

Did you know you can raise events from a user control? Here's a little sample, LabelButton.ascx (essentially the equivalent of asp:LinkButton), that demonstrates implementing a postback event like click. Controls that fires postback events must implement the IPostBackEventHandler interface -- see the first directive of the user control. Cool, huh? LabelButton.ascx <%@ Implements Interface="System.Web.UI.IPostBackEventHandler" %> > ' runat="server"/> And here's a consuming page TestPage.aspx: <%@ Register TagPrefix="ev" TagName="LabelButton" Src="LabelButton.ascx"%>

Create a temp file with VB.NET

Create a temp file with VB.NET

Temp files are generally used for temporary storage and data manipulation. This is often necessary for storing user data, user preferences, session information, application cache, and many other types of information.

In order to get the name of the file that you can use as a temp file in VB.NET, I suggest using the GetTempFileName method of the Path class. While there are multiple approaches to creating a temp file, it's really helpful to use the System.IO.Path because it returns a unique file name in the current user's temporary directory; you can use that file name to create a file for storing temporary information. Note that calling this method multiple times will result in getting a different file name each time even if you don't use that name to create a file. This behavior prevents name collisions between multiple applications.

In my sample code, I define the string variable, sTempFileName, and assign the System.IO.Path.GetTempFileName method's return value to it. This produces a temp file name that I can use. I then create a FileStream object, fsTemp, and request that the system create a file with the filename, sTempFileName. Once the file is created, I add data to it (this code is omitted in the example). After that, the temp file is closed.

Private Sub TempFile() Dim sTempFileName AsString = System.IO.Path.GetTempFileName() Dim fsTemp AsNew System.IO.FileStream(sTempFileName, IO.FileMode.Create) MessageBox.Show(sTempFileName) 'write data to the temp file fsTemp.Close() System.IO.File.Delete(sTempFileName) End Sub

Somthing about 3-Tier architecture

Three Layer:

  1. DAL (Data Access Layer)
  2. BLL (Business Logic Layer)
  3. PL ( Presentation Layer)

· All code that is specific to the underlying data source – such as creating a connection to the database, issuing SELECT, INSERT, UPDATE, and DELETE commands, and so on – should be located in the DAL.

· Data Access Layers typically contain methods for accessing the underlying database data.

· The presentation layer should not contain any references to such data access code, but should instead make calls into the DAL for any and all data requests.

In n-tier models, which tier is best suited for implementing the view, and controller components of an MVC application?

A Client Tier B Web Tier C MVC Tier D Business Tier E EIS Integration Tier F EIS Tier

Encrypting .NET configuration files through code

Encryption support for configuration files was added to the .NET Framework beginning with version 2.0. The .NET Framework libraries include full support for controlling encryption and decryption in code. I include examples in both VB.NET and C# to demonstrate the encrypting and decryption of configuration file sections.

Protect sensitive data

Encrypting configuration data improves application security by making it difficult for users to view the data even if they access the configuration file. There are two protected configuration providers included with ASP.NET: RSAProtectedConfigurationProvider and DPAPIProtectedConfigurationProvider. RSAProtectedConfigurationProvider uses the RSACryptoServiceProvider to encrypt configuration sections using RSA public key encryption to encrypt and decrypt data. DPAPIProtectedConfigurationProvider uses the Windows Data Protection API (DPAPI) to encrypt configuration sections using the built-in cryptography capabilities of Windows. You can also create your own protected settings providers if needed. While a user will have a hard time dealing with encrypted data, ASP.NET has no problems. You can use both of these providers in ASP.NET code.

Using code

The .NET Framework 2.0 allows you to encrypt most configuration sections within the Web.config or machine.config files. The System.Web.Configuration namespace is used to encrypt configuration files via code. It contains two methods associated with encryption: ProtectSection and UnprotectSection.

|> ProtectSection: Marks a configuration section for protection. The name of the provider to be used for the encryption is passed to the method as its only parameter (a string value). |> UnprotectSection: Removes the protected configuration encryption from the associated configuration section. It has no parameters.

As an example, the following simple ASP.NET web.config file demonstrates encryption and decryption of configuration data:

The following VB.NET code from an ASP.NET Web form encrypts the connectionStrings section of the file:

Public Sub Page_Load() Dim config As Configuration Dim configSection As ConfigurationSection config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath) If Not (config Is Nothing) Then configSection = config.GetSection("connectionStrings") If Not (configSection Is Nothing) Then If Not (configSection.SectionInformation.IsLocked) Then configSection.SectionInformation.ProtectSection ("DataProtectionConfigurationProvider") config.Save() End If End If End If End Sub

The code performs the following steps:

|> It uses the System.Web.Configuration namespace to work with the necessary classes. |> It accesses the application's web.config file via the OpenWebConfiguration method of the WebConfigurationManager class. |> It accesses the connectionStrings section of the web.config file via the GetSection method. |> The section is encrypted using the default Windows encryption scheme if the file is not locked. |> The changes to the file are saved.

The equivalent C# code follows.

protected void Page_Load(object sender, EventArgs e) { Configuration config; ConfigurationSection configSection; config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); configSection = config.GetSection("connectionStrings"); if (configSection != null) { if (!(configSection.SectionInformation.IsLocked)) { configSection.SectionInformation.ProtectSection(" DataProtectionConfigurationProvider"); config.Save(); } } }

Once the code runs, the connectionStrings section of my web.config now appears like the following:

AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAaZ2eussTfEmhwe+kgLsWVwQAAAACAAA AAAADZgAAqAAAABAAAADnyhn4dHzOLGFsIj8QUrXgAAAAAASAAACgAAAAEAAAAKFRR3MAelpxxV6J+KEhfq nQAAAAFJOBaI5ciKhw3Ywra+G0hkZb67k0YTJmXYe5+5cpZ3Wd3H2696mEhAGQiTecOVGixqtF9lHa+Qipm MSHcVECiWYjOh/6CIQL6GED37erb4TLZSNo4U7FrE2JscNCnKaKZUtvnxVqRmjcDWU7Gm2rYRAHoDSEy0UE 7ebbcqr7LQ+Y+C7WrFk+VKf6NmN4js4vl7TJXl/Nr36Z65bvZDCxcle66rZ2yebtXMTP2bX95NasbQx0trv njJrdIdMMrLOqLDPhQLwZ4ObCxkh+Rlg4NxQAAABU+1akHFhrg+4d0AmCGE8Egt3HrA==

The following VB.NET code decrypts the section and displays its value:

Public Sub Page_Load() Dim config As Configuration Dim configSection As ConfigurationSection config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath) configSection = config.GetSection("connectionStrings") If Not (configSection Is Nothing) Then If Not (configSection.SectionInformation.IsLocked) Then configSection.SectionInformation.UnprotectSection() config.Save() End If End If End Sub

The code follows the same flow as the encrypt example with the lone exception of being the call to the UnprotectSection method to decrypt the specific section. The equivalent C# code follows:

protected void Page_Load(object sender, EventArgs e) { Configuration config; ConfigurationSection configSection; config = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath); configSection = config.GetSection("connectionStrings"); if (configSection != null) { if (!(configSection.SectionInformation.IsLocked)) { configSection.SectionInformation.UnprotectSection();config.Save(); } } }

Encrypting non-Web applications

The .NET Framework supports also this type of encryption with configuration files for non-ASP.NET applications. For instance, the System.Configuration namespace includes encryption support. It follows the same approach as the previous ASP.NET examples except the Configuration class from the System.Configuration namespace is used to gain access to the configuration file. The following VB.NET code demonstrates working with an application's app.config file:

Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None) Dim configSection ConfigurationSection configSection = config.ConnectionStrings If Not (configSection Is Nothing) Then If Not (configSection.ElementInformation.IsLocked) Then configSection.SectionInformation.ProtectSection ("DataProtectionConfigurationProvider") configSection.SectionInformation.ForceSave = True config.Save(ConfigurationSaveMode.Full) End If End If

The section is easily decrypted with the following VB.NET code:

Dim config As System.Configuration.Configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None) Dim configSection ConfigurationSection configSection = config.ConnectionStrings If Not (configSection Is Nothing) Then If Not (configSection.ElementInformation.IsLocked) Then configSection.SectionInformation.UnprotectSection() configSection.SectionInformation.ForceSave = True config.Save(ConfigurationSaveMode.Full) End If End If

Performance

As with everything that adds security, encrypting and decrypting configuration file sections adversely affects performance. You should test an application both with and without encryption to determine the effects for certain applications. With that said, you should only encrypt what is necessary, such as only those configuration sections that contain sensitive information like connection string and user information.

Don't make it easy

Encryption provides another roadblock for malicious users looking to gain access to sensitive information. The .NET Framework allows you to easily encrypt and decrypt configuration files using built-in or custom encryption schemes.

What kind of data do you store in configuration files? Have you used other encryption schemes in the past to hide the information? Share your experience and thoughts with the .NET community.

Draw/Paint a Header Checkbox in Gridview

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.Collections;

namespace Samples

{

public partial class General : Form

{

public General()

{

InitializeComponent();

}

myColHeader hCell;

private void General_Load(object sender, EventArgs e)

{

DataTable dt = new DataTable();

dt.Columns.Add("status",typeof(bool));

dt.Rows.Add(true);

dt.Rows.Add(false);

dt.Rows.Add(true);

dt.Rows.Add(false);

dt.Rows.Add(true);

this.dataGridView1.DataSource = dt;

hCell = new myColHeader();

this.dataGridView1.Columns[0].HeaderCell = hCell;

}

private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)

{

if (e.ColumnIndex == 0)//the checkbox col

{

for (int j = 0; j < this.dataGridView1.Rows.Count - 1; j++)

{

this.dataGridView1.Rows[j].Cells[0].Value = hCell.CheckAll;

}

}

}

}

class myColHeader:DataGridViewColumnHeaderCell

{

private Rectangle CheckBoxRegion;

private bool checkAll = false;

protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates dataGridViewElementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)

{

base.Paint(graphics, clipBounds, cellBounds, rowIndex, dataGridViewElementState, value,

formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

graphics.FillRectangle(new SolidBrush(cellStyle.BackColor), cellBounds);

CheckBoxRegion = new Rectangle(

cellBounds.Location.X+1,

cellBounds.Location.Y+2,

25, cellBounds.Size.Height-4);

if (this.checkAll)

ControlPaint.DrawCheckBox(graphics, CheckBoxRegion, ButtonState.Checked);

else

ControlPaint.DrawCheckBox(graphics, CheckBoxRegion, ButtonState.Normal);

Rectangle normalRegion =

new Rectangle(

cellBounds.Location.X + 1 + 25,

cellBounds.Location.Y,

cellBounds.Size.Width - 26,

cellBounds.Size.Height);

graphics.DrawString(value.ToString(), cellStyle.Font, new SolidBrush(cellStyle.ForeColor), normalRegion);

}

protected override void OnMouseClick(DataGridViewCellMouseEventArgs e)

{

//Convert the CheckBoxRegion

Rectangle rec = new Rectangle(new Point(0,0),this.CheckBoxRegion.Size);

this.checkAll = !this.checkAll;

if (rec.Contains(e.Location))

{

this.DataGridView.Invalidate();

}

base.OnMouseClick(e);

}

//Property

public bool CheckAll

{

get { return this.checkAll; }

set { this.checkAll = value; }

}

}

}

CheckAll checkbox in GridView

private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)

{

if (e.RowIndex == -1 )

{

int i;

for (i = 0; i <>

{

this.dataGridView1.EndEdit();

string re_value = this.dataGridView1.Rows.Cells[0].EditedFormattedValue.ToString();

this.dataGridView1.Rows.Cells[0].Value = "true";

this.dataGridView1.Rows.Selected = true;

}

}

}

=============================================================

private void checkBox1_CheckedChanged(object sender, EventArgs e) {

foreach (DataGridViewRow row in dataGridView1.Rows)

row.Cells[0].Value = checkBox1.Checked;

}

Edititng data in a table

When you make changes to column values in a DataRow, the changes are immediately placed in the current state of the row. The DataRowState is then set to Modified, and the changes are accepted or rejected using the AcceptChanges or RejectChanges methods of the DataRow. The DataRow also provides three methods that you can use to suspend the state of the row while you are editing it. These methods are BeginEdit, EndEdit, and CancelEdit.

When you modify column values in a DataRow directly, the DataRow manages the column values using the Current, Default, and Original row versions. In addition to these row versions, the BeginEdit, EndEdit, and CancelEdit methods use a fourth row version: Proposed. For more information about row versions, see Row States and Row Versions.

The Proposed row version exists during an edit operation that begins by calling BeginEdit and that ends either by using EndEdit or CancelEdit, or by calling AcceptChanges or RejectChanges.

During the edit operation, you can apply validation logic to individual columns by evaluating the ProposedValue in the ColumnChanged event of the DataTable. The ColumnChanged event holds DataColumnChangeEventArgs that keep a reference to the column that is changing and to the ProposedValue. After you evaluate the proposed value, you can either modify it or cancel the edit. When the edit is ended, the row moves out of the Proposed state.

You can confirm edits by calling EndEdit, or you can cancel them by calling CancelEdit. Note that while EndEdit does confirm your edits, the DataSet does not actually accept the changes until AcceptChanges is called. Note also that if you call AcceptChanges before you have ended the edit with EndEdit or CancelEdit, the edit is ended and the Proposed row values are accepted for both the Current and Original row versions. In the same manner, calling RejectChanges ends the edit and discards the Current and Proposed row versions. Calling EndEdit or CancelEdit after calling AcceptChanges or RejectChanges has no effect because the edit has already ended.

The following example demonstrates how to use BeginEdit with EndEdit and CancelEdit. The example also checks the ProposedValue in the ColumnChanged event and decides whether to cancel the edit.

Visual Basic

CopyCode imageCopy Code

Dim workTable As DataTable = New DataTable

workTable.Columns.Add("LastName", Type.GetType("System.String"))

AddHandler workTable.ColumnChanged, _

New DataColumnChangeEventHandler(AddressOf OnColumnChanged)

Dim workRow As DataRow = workTable.NewRow()

workRow(0) = "Smith"

workTable.Rows.Add(workRow)

workRow.BeginEdit()

' Causes the ColumnChanged event to write a message and cancel the edit.

workRow(0) = ""

workRow.EndEdit()

' Displays "Smith, New".

Console.WriteLine("{0}, {1}", workRow(0), workRow.RowState)

Private Shared Sub OnColumnChanged( _

sender As Object, args As DataColumnChangeEventArgs)

If args.Column.ColumnName = "LastName" Then

If args.ProposedValue.ToString() = "" Then

Console.WriteLine("Last Name cannot be blank. Edit canceled.")

args.Row.CancelEdit()

End If

End If

End Sub

C#

CopyCode imageCopy Code

DataTable workTable = new DataTable();

workTable.Columns.Add("LastName", typeof(String));

workTable.ColumnChanged +=

new DataColumnChangeEventHandler(OnColumnChanged);

DataRow workRow = workTable.NewRow();

workRow[0] = "Smith";

workTable.Rows.Add(workRow);

workRow.BeginEdit();

// Causes the ColumnChanged event to write a message and cancel the edit.

workRow[0] = "";

workRow.EndEdit();

// Displays "Smith, New".

Console.WriteLine("{0}, {1}", workRow[0], workRow.RowState);

protected static void OnColumnChanged(

Object sender, DataColumnChangeEventArgs args)

{

if (args.Column.ColumnName == "LastName")

if (args.ProposedValue.ToString() == "")

{

Console.WriteLine("Last Name cannot be blank. Edit canceled.");

args.Row.CancelEdit();

}

}