I had to show an alert on a button click,but when ever i "OK" it always postsback.
To avoid such a thing simply we can use HTML Control.
have the following code in code-behind window.
Button.Attributes.Add("onclick","alert('Are You Sure ??');return false;");
This will prevent postback....
Monday, December 29, 2008
Avoid Postback
Friday, November 21, 2008
Differences Between Properties and Indexers in C#
Properties:
1)Identified by its name.
2)Accessed through a simple name or a member access.
3)Can be a static or an instance member.
4)A get accessor of a property has no parameters.
5)A set accessor of a property contains the implicit value parameter.
Indexers:
1)Identified by its signature.
2)Accessed through an element access.
3)Must be an instance member.
4)A get accessor of an indexer has the same formal parameter list as the indexer.
5)A set accessor of an indexer has the same formal parameter list as the indexer, in addition to the value parameter.
config files in .Net
Web.config:--Basically this file is use for web setting or we can say web.config file contains setting to a web application.
Machine.config:--Settings to a computer and that help to configure all application into same machine.
Example:--
In a machine it can be more then one web application so each application will have one or more web.config files depend on configuration level of folders but in that system there will be one machine.config file.
Overview of ASP.NET 3.5
ASP.NET has for long been a popular web application development platform. ASP.NET 2.0 added a lot of new features compared to its earlier counterpart, i.e., ASP.NET 1.1. With ASP.NET 3.5, you have even more features. This article will present the new features that have been added to ASP.NET and Visual Studio 2008.
In ASP.NET 3.5, a new tool has been introduced called the ASP.NET Merge Tool. You can use this tool for merging pre-compiled assemblies. No, this is not all. There isa lot of other exciting features and we will explore each of them as we progress through this article.
The most significant improvements in ASP.NET are:
* Integrated Ajax Support
* New Data Controls (ListView and DataPager)
* The LinqDataSource Control
Visual Studio 2008 has also included some features for an improved web application development experience. Here is the list of such improvements:
* Support for LINQ
* IntelliSense for JavaScript and ASP.NET Ajax
* Improved Design time experience
Please refer to below link for detailed explantion
http://aspnet.4guysfromrolla.com/articles/112107-1.aspx
Sunday, August 31, 2008
New Version of ODP.NET
Oracle just released its latest version of ODP.NET. This version, for Oracle 11g, provides enhancements and the much anticipated Instant Client and User Defined Types (UTDs). One big issue in the past when you were working with ODP.NET for your ASP.NET applications was that you had to install a tremendously large Oracle client application that took some time. Now with the instant client, you simply XCopy your client to the server you want it at. Very easy. UDTs was also another feature that allows you to pass custom types into the database and step away from the need to use numerous ref cursors.
ODP.NET includes the ASP.NET providers that you might be looking for including:
Membership Provider
Role Provider
Profile Provider
Session State Provider
Site Map Provider
Web Parts Personalization Provider
Web Event Provider
Cache Dependency Provider
You can look to download this version at http://www.oracle.com/technology/tech/windows/odpnet/index.html
Sunday, February 24, 2008
State Management in .Net
Web form pages are HTTP-Based, they are stateless, which means they don’t know whether the requests are all from the same client, and pages are destroyed and recreated with each round trip to the server, therefore information will be lost, therefore state management is really an issue in developing web applications
We could easily solve these problems in ASP with cookie, query string, application, session and so on. Now in ASP.NET, we still can use these functions, but they are richer and more powerful, so let’s dive into it.
Mainly there are two different ways to manage web page’s state:
1) Client-side
2) Server-side
1.Client-side state management :
--> Cookies
You need to store small amounts of information on the client and security is not an issue.
--> View state
You need to store small amounts of information for a page that will post back to itself. Use of the ViewState property does supply semi-secure functionality.
--> Hidden fields
You need to store small amounts of information for a page that will post back to itself or another page, and security is not an issue.
--> Query string
You are transferring small amounts of information from one page to another and security is not an issue.
2. Server-side state management:
--> Application state object
You are storing infrequently changed, application-scope information that is used by many users, and security is not an issue. Do not store large quantities of information in an application state object.
--> Session state object
You are storing short-lived information that is specific to an individual session, and security is an issue. Do not store large quantities of information in a session state object. Be aware that a session state object will be created and maintained for the lifetime of every session in your application. In applications hosting many users, this can occupy significant server resources and affect scalability.
--> Database support
You are storing large amounts of information, managing transactions, or the information must survive application and session restarts. Data mining is a concern, and security is an issue.
Keep watching for information around state Management...
Sunday, December 30, 2007
@Page Directives
@Page directives allow you to set attributes that directly affect your ASP.NET pages that end with the .aspx extension. There are 26 directives available, and you can explore the exhaustive list in the SDK at the link I provided a few paragraphs back, but Table 4.4 contains some of the more commonly used @page directives.
Buffer
As seen in the previous section on the Response object, this sets whether the Buffer is enabled or not. This is true by default and would need to be set explicitly to false.
EnableSessionState
This defines Session-State requirements for the page. If this is set to true (default) then Session-State is enabled; if false Session-State is disabled; or if ReadOnly then Session state can be read but not changed.
EnableViewState
This direct controls whether ViewState(Maintain GUI state) is maintained across page requests. It is true by default.
Explicit
Specifies whether all variables on a page must be declared using a Dim, Private, Public, or ReDim statement in Visual Basic .NET. The default is false.
Inherits
Defines a class from a code-behind page that a page should inherit. (Don't worry, this will be explained is a few short minutes.)
Language
Informs the .NET Framework of the language used for all inline(<% %>) and server-side script blocks within the ASP.NET page.
Src
This contains the name of the source file for an included code-behind page.
Trace
This indicates whether tracing is enabled or not. True is enabled; otherwise false. False is the default. Tracing is a debugging function in ASP.NET that allows you to see diagnostic and debug information about an ASP.NET page.
Saturday, December 29, 2007
Using NHibernate with ASP.NET
NHibernate is a port of Hibernate Core for Java to the .NET Framework. It handles persisting plain .NET objects to and from an underlying relational database. Given an XML description of your entities and relationships, NHibernate automatically generates SQL for loading and storing the objects. Optionally, you can describe your mapping metadata with attributes in your source code.
NHibernate supports transparent persistence, your object classes don't have to follow a restrictive programming model. Persistent classes do not need to implement any interface or inherit from a special base class. This makes it possible to design the business logic using plain .NET (CLR) objects and object-oriented idiom.
Originally being a port of Hibernate 2.1, the NHibernate API is very similar to that of Hibernate. All Hibernate knowledge and existing Hibernate documentation is therefore directly applicable to NHibernate. Take a look at the available NHibernate Documentation.
NHibernate key features:
Natural programming model - NHibernate supports natural OO idiom; inheritance, polymorphism, composition and the .NET collections framework, including generic collections.
Native .NET - NHibernate API uses .NET conventions and idioms
Support for fine-grained object models - a rich variety of mappings for collections and dependent objects
No build-time bytecode enhancement - there's no extra code generation or bytecode processing steps in your build procedure
The query options - NHibernate addresses both sides of the problem; not only how to get objects into the database, but also how to get them out again
Custom SQL - specify the exact SQL that NHibernate should use to persist your objects. Stored procedures are supported on Microsoft SQL Server.
Support for "conversations" - NHibernate supports long-lived persistence contexts, detach/reattach of objects, and takes care of optimistic locking automatically
Free/open source - NHibernate is licensed under the LGPL (Lesser GNU Public License)
Benefits of using stored procedures
Applications that use stored procedures have the following advantages:
---Reduced network usage between clients and servers:
A client application passes control to a stored procedure on the database server. The stored procedure performs intermediate processing on the database server, without transmitting unnecessary data across the network. Only the records that are actually required by the client application are transmitted. Using a stored procedure can result in reduced network usage and better overall performance.
Applications that execute SQL statements one at a time typically cross the network twice for each SQL statement. A stored procedure can group SQL statements together, making it necessary to only cross the network twice for each group of SQL statements. The more SQL statements that you group together in a stored procedure, the more you reduce network usage and the time that database locks are held. Reducing network usage and the length of database locks improves overall network performance and reduces lock contention problems.
Applications that process large amounts of SQL-generated data, but present only a subset of the data to the user, can generate excessive network usage because all of the data is returned to the client before final processing. A stored procedure can do the processing on the server, and transmit only the required data to the client, which reduces network usage.
----Enhanced hardware and software capabilities:
Applications that use stored procedures have access to increased memory and disk space on the server computer. These applications also have access to software that is installed only on the database server. You can distribute the executable business logic across machines that have sufficient memory and processors.
---Improved security:
By including database privileges with stored procedures that use static SQL, the database administrator (DBA) can improve security. The DBA or developer who builds the stored procedure must have the database privileges that the stored procedure requires. Users of the client applications that call the stored procedure do not need such privileges. This can reduce the number of users who require privileges.
---Reduced development cost and increased reliability:
In a database application environment, many tasks are repeated. Repeated tasks might include returning a fixed set of data, or performing the same set of multiple requests to a database. By reusing one common procedure, a stored procedure can provide a highly efficient way to address these recurrent situations.
---Centralized security, administration, and maintenance for common routines:
By managing shared logic in one place at the server, you can simplify security, administration, and maintenance . Client applications can call stored procedures that run SQL queries with little or no additional processing.
Tuesday, November 20, 2007
Visual Studio 2008 released
Microsoft Visual Studio 2008 , code-named Orcas, is the successor to Visual Studio 2005. It was released to MSDN subscribers on 19 November 2007. The codename Orcas is, like Whidbey, a reference to an island in Puget Sound, Orcas Island. The successor to Visual Studio 2008 is codenamed Rosario. The source code for the Visual Studio 2008 IDE will be available under a shared-source license to some of Microsoft's partners and ISVs.
Visual Studio 2008 is focused on development of Windows Vista, 2007 Office system, and Web applications. Among other things, it brings a new language feature, LINQ, new versions of C# and Visual Basic languages, a Windows Presentation Foundation visual designer, and improvements to the .NET Framework. It also features a new HTML/CSS editor influenced by Microsoft Expression Web. Visual Studio 2008 requires .NET Framework 3.5 and by default configures compiled assemblies to run on .NET Framework 3.5; but it also supports multi-targeting which lets the developers choose which version of the .NET Framework (out of 2.0, 3.0, 3.5, Silverlight CoreCLR or .NET Compact Framework) the assembly runs on. Visual Studio 2008 also includes new code analysis tools, including the new Code Metrics tool.
Visual Studio 2008 features a XAML based designer (codenamed Cider), workflow designer, LINQ to SQL designer (for defining the type mappings and object encapsulation for SQL data), XSLT debugger, XSD designer, JavaScript Intellisense support, JavaScript Debugging support, support for UAC manifests, a concurrent build system, among others. It also ships with an enhanced set of UI widgets, both for WinForms and WPF. It also includes a multithreaded build engine to compile multiple source files (and build the executable file) in a project across different threads simultaneously.
