Monday, July 26, 2004

manipulating drop-downs in template column of datagrid

Code snippet for demonstration of manipulating drop-downs in template column of datagrid:

Copy the following between the
tags of the aspx page in HTML view.























Copy the following in the Page_Load method in code-behind or

between the tags



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

{

DataTable dt = new DataTable();

DataRow dr;

DropDownList ddl;

int i;



//Create the datasource for the datagrid

dt.Columns.Add("col1", Type.GetType("System.String"));

for(i = 0; i < 5; i++)

{

dr = dt.NewRow();

dr[0] = i.ToString();

dt.Rows.Add(dr);

}



//bind datasource to the datagrid

dgtest.DataSource = dt;

dgtest.DataBind();



//manipulate the drop-down list of each row of the datagrid.

//this code simply displays the ID as the sole element of the drop-down.

for(i = 0; i < dgtest.Items.Count; i++)

{

ddl = (DropDownList)dgtest.Items[i].FindControl("ddltest");



if(ddl != null)

{

ddl.Items.Clear();

ddl.Items.Add(i.ToString());

}

}

}



output:

ID ¦

-------------------

0 ¦ | 0 |v|

1 ¦ | 1 |v|

2 ¦ | 2 |v|

3 ¦ | 3 |v|

4 ¦ | 4 |v|

Server.Transfer VS Response.Redirect


Server.Transfer VS Response.Redirect











Server.Transfer is often a
better choice than Response.Redirect.


Example: Let's say
you're on A.aspx and you want to send the user to B.aspx.


Response.Redirect
flow

A.aspx calls Response.Redirect("B.aspx",false); which sends a 302 redirect
header down to the client browser, telling it that the asset it has requested
(A.aspx) has moved to B.aspx, and the web application terminates. The client
browser then sends a request to the webserver for B.aspx. IIS tells asp_wp.exe
to process the request. asp_wp.exe (after checking authentication and doing all
the other setup stuff it needs to do when a new request comes in) instantiates
the appropriate class for B.aspx, processes the request, sends the result to the
browser, and shuts down.


Server.Transfer
flow

A.aspx calls Server.Transfer("B.aspx");. ASP.NET
instantiates the appropriate class for B.aspx, processes the request, sends the
result to the browser, and shuts down.


Note that Server.Transfer
cuts the load on the client and the server.

Server.Transfer is easier to
code for, too, since you maintain your state. Information can be passed through
the HTTP Context object between the pages, eliminating the need to pass
information in the querystring or reload it from the database.


More info http://dotnetjunkies.com/WebLog/familjones/archive/2004/04/08/11020.aspx and http://www.eggheadcafe.com/articles/20030531.asp.



Regards,
Mitesh Mehta
Microsoft Certified Professional
Direct Information Pvt. Ltd.,

How to create pie charts in web applns

How to create pie charts in web applns









Pie Chart in ASP.net



<%@ Import Namespace="System.Drawing"%>
<%@ Import Namespace="System.Drawing.Imaging"%>
<%@ Import Namespace="System.Drawing.Drawing2D" %>
<script language="C#" runat="server">

void Page_Load(Object sender, EventArgs e)
{
// Since we are outputting a Jpeg, set the ContentType appropriately
Response.ContentType = "image/jpeg";

// Create a Bitmap instance that's 468x60, and a
Graphics instance

const int width = 300, height = 300;

Bitmap objBitmap = new Bitmap(width, height);
Graphics objGraphics = Graphics.FromImage(objBitmap);

// Create a black background for the border
objGraphics.FillRectangle(new SolidBrush(Color.White), 0, 0,
width, height);

Draw3DPieChart(ref objGraphics);

// Save the image to a file
objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg);

// clean up...
objGraphics.Dispose();
objBitmap.Dispose();
}

// Draws a 3D pie chart where ever slice is 45 degrees in value
void Draw3DPieChart(ref Graphics objGraphics)
{
int iLoop, iLoop2;

// Create location and size of ellipse.
int x = 50;
int y = 20;
int width = 200;
int height = 100;

// Create start and sweep angles.
int startAngle = 0;
int sweepAngle = 45;
SolidBrush oibjBrush = new SolidBrush(Color.Aqua);

Random rand = new Random();
objGraphics.SmoothingMode = SmoothingMode.AntiAlias;

//Loop through 180 back around to 135 degress so it gets drawn
// correctly.

for( iLoop = 0; iLoop <= 315; iLoop += 45)
{
startAngle = (iLoop + 180) % 360;
objBrush.Color = Color.FromArgb(rand.Next(255), rand.Next(255),
rand.Next(255));

// On degrees from 0 to 180 draw 10 Hatched brush slices to show
// depth

if((startAngle < 135) || (startAngle == 180))
{
for(iLoop2 = 0; iLoop2 < 10; iLoop2++)
objGraphics.FillPie(new HatchBrush(HatchStyle.Percent50,
objBrush.Color), x,
y + iLoop2, width, height, startAngle, sweepAngle);
}

// Displace this pie slice from pie.
if(startAngle == 135)
{
// Show Depth
for(iLoop2 = 0; iLoop2 < 10; iLoop2++)
objGraphics.FillPie(new HatchBrush(HatchStyle.Percent50,
objBrush.Color), x - 30,
y + iLoop2 + 15, width, height, startAngle,
sweepAngle);

objGraphics.FillPie(objBrush, x - 30, y + 15,
width, height, startAngle, sweepAngle);
}
else // Draw normally
objGraphics.FillPie(objBrush, x, y, width,
height, startAngle, sweepAngle);
}
}
</script>






Mitesh Mehta
Microsoft Certified Professional


How to create pie charts in web applns

How to create pie charts in web applns









SVG : Scalable Vector Graphics is an exciting new XML-based language for Web graphics from the World Wide Web Consortium (W3C).
For more info on SVG you can visit Adobe's SVG Zone.
VML : Vector Markup Language is an application of Extensible Markup Language (XML) 1.0
which defines a format for the encoding of vector information together
with additional markup to describe how that information may be
displayed and edited.
For more info on VML please check out W3.org's VML Specification.
regards
Mitesh Mehta
Microsoft Certified Professional

Friday, July 23, 2004

Session State in ASP.Net


Session State in ASP.Net







Session State in ASP.Net

ASP.Net supports three different providers for Session State...
They are:

InProc - Session values are kept live in the memory of ASP.Net worker process
StateServer - Session values are serialized to store in the memory of a
separate process i.e. aspnet_state.exe
SQLServer - Session values are stored on SQL Server...

Mitesh Mehta
Microsoft Certified Professional
Mail : miteshvmehta@gmail.com
C# FAQ
C# Code
SQL Server 2005
VB.NET 2005
ASP.NET Help










mode="SQLServer" for sessionState

When you choose your sessionState to be SQLServer, ASP.Net uses the default
DB and initial catalogs for storing your session information into
SQLServer... That is the reason you are not allowed to pass tokens such as
Database and Initial Catalog in the connection string... Finally your entry
in the web.config file will look like

<configuration>
<system.web>
<sessionState
mode="SQLServer"
sqlConnectionString="server=127.0.0.1;uid=<user
id>;pwd<password>" />
</system.web>
</configuration>

user id and password can be replaced by integrated security settings...

Mitesh Mehta
Microsoft Certified Professional



Thursday, July 22, 2004

Changes to Validation Controls in ASP.NET 2.0


Changes to Validation Controls in ASP.NET 2.0










While ASP.NET 1.x supported validating user input, ASP.NET 2.0 increases
the flexibility of the validation through the addition of validation groups.
This article looks at this new feature, and shows you how you can use it in a
number of common scenarios.




Regards,
Mitesh Mehta
Microsoft Certified Professional
miteshvmehta@gmail.com

ASP.NET 2.0 Custom Controls


ASP.NET 2.0 Custom Controls









Creating ASP.NET 2.0 Custom Controls




Summary: The new adaptive rendering model in ASP.NET 2.0
provides a number of new options for control writers. This article shows how
those options make creating custom controls for ASP.NET easier than
before.


Regards,
Mitesh Mehta
Microsoft Certified Professional
miteshvmehta@gmail.com

Personalization with ASP.NET 2.0


Personalization with ASP.NET 2.0










Personalizing a Web site has always involved a large amount of complex
supporting code. With the new personalization features in ASP.NET 2.0, however,
developers can not only create personalized applications faster, they can also
build entirely new classes of applications. The user management system and login
controls make recognizing a user even easier than before, and the profile
features help store user data in a fast and efficient manner. The Web Parts
framework, however, provides a revolutionary new design paradigm for Web sites.
Thanks to Web Parts, a Web site is no longer constrained to the linear document
format that formed the basis for the HTML standard. Web Parts offer much greater
flexibility, and allow developers to create Web applications that are almost
indistinguishable from the most powerful desktop systems.


Read More...


http://msdn.microsoft.com/asp.net/whidbey/default.aspx?pull=/library/en-us/dnvs05/html/person_fin.asp#person_topic11



Regards,
Mitesh Mehta

Visual Studio for WebService Development - Free!


Visual Studio for WebService Development - Free!











You might have noticed but
again, the recently announced

Visual Studio 2005 Express Beta
allows doing Web Service development. Download the
Visual Web Developer
2005 Express Edition Beta
and one of the types of projects you
can create is a Web service project.

Here's the default C# Web
service project:


using
System.Web;
using System.Web.Services;
using
System.Web.Services.Protocols;

[WebServiceBinding(ConformanceClaims=WsiClaims.BP10,
EmitConformanceClaims = true)]
public class Service :
System.Web.Services.WebService {

[WebMethod]
public
string HelloWorld() {
return "Hello World";
}

}


You can even use Visual Basic
or C++.


Regards,
Mitesh Mehta
Microsoft Certified Professional
miteshvmehta@gmail.com

Saturday, July 17, 2004

WSE 2.0 - What's New and Different in WSE 2.0?


WSE 2.0 - What's New and Different in WSE 2.0?










Web Services Enhancements
for Microsoft .NET version 2.0 includes a number of enhancements over earlier
versions of WSE like:


Policy
WS-Trust and
Security Context Tokens
Kerberos Security Tokens
Role-based Security Using
Security Tokens
Signing and Encrypting Security Tokens
SOAP
Messaging
XML Security Token Support

To read more on WSE 2.0
Enhancement features go to ->




Regards,
Mitesh Mehta
M.C.P.

miteshvmehta@gmail.com

New data source components in ASP.NET 2.0


New data source components in ASP.NET 2.0










This article discusses:

http://msdn.microsoft.com/data/archive/default.aspx?pull=/msdnmag/issues/04/06/aspnet20data/default.aspx
New
data source components in ASP.NET 2.0
Binding to business objects and XML
data
GridView and DetailsView controls


Summary:
Data source controls make codeless binding
possible, but seldom practical in real-world situations. Some code must always
be written to fine tune the page, but data source controls significantly reduce
the quantity. Data source controls also integrate caching capabilities and allow
you to enable caching declaratively. Everything happens behind the scenes so you
can deliver best-practice code with almost no effort.


Data source controls enable a consistent model across a variety of data
sources. You can use the same data-binding model regardless of whether the data
source is a SQL table, an XML document, a business object, a site map, or even
an Excel worksheet. The new architecture is more automatic in nature, but works
side-by-side with the old model based on enumerable objects.


Regards,
Mitesh V. Mehta
Microsoft Certified Professional

miteshvmehta@gmail.com

Friday, July 16, 2004

New data source components in ASP.NET 2.0


New data source components in ASP.NET 2.0










This article discusses:



New
data source components in ASP.NET 2.0
Binding to business objects and XML
data
GridView and DetailsView controls


Summary:
Data source controls make codeless binding
possible, but seldom practical in real-world situations. Some code must always
be written to fine tune the page, but data source controls significantly reduce
the quantity. Data source controls also integrate caching capabilities and allow
you to enable caching declaratively. Everything happens behind the scenes so you
can deliver best-practice code with almost no effort.


Data source controls enable a consistent model across a variety of data
sources. You can use the same data-binding model regardless of whether the data
source is a SQL table, an XML document, a business object, a site map, or even
an Excel worksheet. The new architecture is more automatic in nature, but works
side-by-side with the old model based on enumerable objects.


Regards,
Mitesh V. Mehta
Microsoft Certified Professional

miteshvmehta@gmail.com

Monday, July 12, 2004

Article: Improved Caching in ASP.NET


Article: Improved Caching in ASP.NET










New caching feature
included in ASP.NET 2.0, improves the performance and scalability of ASP.NET
applications. The ASP.NET 2.0 framework includes a number of significant new
enhancements that make it easier to take advantage of caching in
applications.

The new DataSource
controls include properties that make it easy to cache database data in memory.
By taking advantage of the DataSource controls, database data can be
retrieved and cached without writing a single line of code.


The new support for SQL Cache
Invalidation enables to automatically reload database data in the cache whenever
the data is modified in the underlying database. This feature provides all the
performance benefits of caching, without the worries of stale data.


Finally, the new
Substitution
control enables more easily mix dynamic content in a cached
page. The Substitution control gives an island of dynamic content in an
cached page.


You can find more details in
below URL:


http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/CachingNT2.asp



Regards,
Mitesh Mehta


Thursday, July 08, 2004

What's new in ASP.NET 2.0?

What's new in ASP.NET 2.0?














allowOverride Attribute







allowOverride Attribute

If you have a common server where you are going to host your website and you
do not want anyone to override your configuration settings after the site is
deployed then within your web.config file, use < location > tag and set
allowOverride attribute to false....


Mitesh Mehta
If You Think YOU CAN... You Can...

Controls


Controls












Web Server Control: provide a programming model that is more conducive to visual design environments similar to VB
Usage
wise i have seen people prefer HTML controls to hande client site
events (javascript) and ServerControls to hande server side events. you
can add runat server attribute to htmlcontrols and handle server side
events also
<asp:textbox>
vs the <input runat=server> tags , when to use one and the other,
it's up to what you're doing. In general, I would go with the
webcontrols.
Regards,
Jignesh Desai.


Installer for Globalization










Installer for Globalization

If you have different versions of your web application built for different
languages and you have separate resource files for each language when you
need to deploy your application according to the language settings of the
server then in that case make an Installer that has Custom Action to install
only location-specific files...

Vishal Joshi
Microsoft MVP .Net
If You Think YOU CAN... You Can...


Wednesday, July 07, 2004

Mixing Forms and Windows Security in ASP.NET







ASP.NET
developers have been asking for a way to combine Forms and Windows
security. Paul Wilson provides a solution that does just that; it
captures the Windows username, if possible, and otherwise redirects
users to a logon screen.
Check it our here

Article: ASP.NET Grid View







This article discusses:
  • The ASP.NET 2.0 GridView, FormView, and DetailsView
  • Differences between the DataGrid and the GridView
  • The programming interfaces of these controls
  • How to achieve master/detail views
Very interesting and informative..
Rgds,
Mitesh Mehta

MVC Architecture in ASP.Net


The example Nitin have given is an example of Observer Pattern.where
subject notifies to all the observer if it(subject) gets changed. In
MVC pattern there are main three entity Model View and as you know
Controller. In this architecture following kind of transactions
occurs...

  1. View Requests to Controller for data.
  2. Controller fetch the data from the model and updates the view.
  3. View reuest controller to update the data.
  4. Controller updates the data on the modle.
These
kind of trasactions keeps on occuring among the View, Controller and
Model. ASP.Net allow us to use this pattern the form of Codebehind.
where your aspx page is view, you codebehind base class is controller
and your database or any persistant storage is modle...
Hope you got the answer...




MVC Architecture in ASP.Net









to understand the concept better

there are few articles:



This is very good site of OOPS
also..