|
Knowledge base
|
|
|
|
|
|
|
 |
|
 |
|
|
|
|
|
|
|
|
|
 |
|
 |
|
| TRULY Understanding ViewState ViewState is a very misunderstood animal. I would like to help put an end to the madness by attempting to explain exactly how the ViewState mechanism works, from beginning to end, and from many different use cases, such as declared controls vs. dynamic controls.
There are a lot of great articles out there that try to dispel the myths about ViewState. You might say this is like beating a dead horse (where ViewState is the horse, and the internet is the assailant). But this horse isn't dead, let me tell you. No, he's very much alive and he's stampeding through your living room. We need to beat him down once again. Don't worry, no horses were harmed during the authoring of this article.
|
| Understanding ASP.NET View State Scott Mitchell looks at the benefits of and confusion around View State in Microsoft® ASP.NET. In addition, he shows you how you can interpret (and protect) the data stored in View State. |
| Dynamic Web Controls, Postbacks, and View State ASP.NET makes it easy to programmatically add Web controls. Armed with this capability, you can offer a truly customized experience for your users. For example, your site might load particular navigational elements as user controls, based upon the logged on user's preferences. Or when collecting information from your users, you might display different input fields prompting for different data based on the user's age, location, gender, and so on. |
| ASP.NET State Management: View state ASP.NET view state is a great feature and an essential tool for web development of today. It maintains the state of a page as it travels back and forth. There is no more need to worry about restoring values of page controls between postbacks. In this article you will get an in-depth perspective on view state. We will talk about ways of reducing unnecessary payload and protecting view state from prying eyes. |
| Coding Horror: Web Farms and ASP.NET View state ASP.NET ViewState is tied to the particular server it came from by default-- even though the documentation says it isn't. So when ViewState generated on server A is POST-ed back to server B, you'll get this exception. Somewhere in the pipeline, the viewstate is salted with a unique, autogenerated machine key from the originating server's machine.config file |
|
|
|
|
|
|
|
|
 |
|
 |
|
| Dynamic controls, postbacks and viewstate data Many developers out there use a well known technique for dynamically loading an .ascx into another custom .ascx. That technique is applied in the code behind and there are many variants of that code created by many developers out there.
The first thing you may know is that when a control is loaded into a asp.net page, it must be loaded every time a postback request is made to the server because it need to render itself every time until we decide to use a new control.
Our problem starts when the dynamically loaded control tries to read/write data from the viewstate and also when the loader control tries to do the same. The problem is that the viewstate data is only active between a few steps of the page lifecycle as we will see
|
| DynamicControlsPlaceholder - A placeholder that saves its child controls Problem:
ASP.NET gives a developer the opportunity to programmatically add controls to a web form using ParentControl.Controls.Add(new Control());
However, these controls are not persisted in any way thus having to be recreated for each subsequent request.
Goal:
To create a control that behaves like a placeholder but additionally handles recreating dynamic controls on subsequent requests.
|
|
|
|
|
|
|
|
|
 |
|
|
|
FormatString
|
 |
|
 |
|
| String.Format Method (String, Object) Replaces the format item in a specified String with the text equivalent of the value of a specified Object instance.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
|
| String.Format("{0}", "formatting string"}; One of the painful things about good old ASP was string formatting, VBScript simply didn't have anything useful. C# (and VB.Net) do, but MSDN doesn't provide a quick reference to the formatting options. So here's a quick reference.
|
|
|
|
|
|
|
|
|
 |
|
|
|
Data Validation
|
 |
|
 |
|
| Adding a validator to an edit field in Telerik RadGrid In order to prevent the update operation if the user enters data in an edit field which is not in the correct format, you can wire the ItemCreated event of the grid to add a validator of your choice. There are four stages which need to be passed:
Check whether the current item is in edit mode;
Obtain reference to the respective GridColumnEditor instance and the editing control inside it;
Create the validator and set its ControlToValidate property to point to the editing control;
Add the validator to the Controls collection of the editing control Parent. |
|
|
|
|
|
|
|
|
 |
|
|
|
Security
|
 |
|
 |
|
| Securing Your Application An important part of many Web applications is the ability to identify users and control access to resources. The act of determining the identity of the requesting entity is known as authentication. Generally, the user must present credentials, such as a name/password pair in order to be authenticated. Once an authenticated identity is available, it must be determined whether that identity can access a given resource. This process is known as authorization. ASP.NET works in conjunction with IIS to provide authentication and authorization services to applications. |
|
|
|
|
|
|
|
|
 |
|
|
|
Office in ASP.NET
|
 |
|
 |
|
| ASP.NET- "Download as Word/Excel" Due to the popularity & convenience that Microsoft Word & Excel offer, you may have run into umpteen sites that offer visitors to download reports or the like as Word or Excel documents. While this can be accomplished with Office Automation or expensive tools, be aware that is there a lightweight technique available. |
|
|
|
|
|
|
|
|
 |
|
|
|
DataSources
|
 |
|
 |
|
| BASICS: ObjectDataSource Control ObjectDataSource is a new hybrid control for ASP.NET 2.0 This article shows an unusual use of the control to retrieve and display RSS Feed search results from the web, instead of getting data from a database. |
| Some Tips and Tricks for using an ObjectDataSource with a Gridview This article attempts to show a few tricks with the new Gridview that we have in asp.net 2.0. This article addresses using the ObjectDataSource to populate the Gridview. In this example the ObjectDataSource returns a generic collection of an object. There is some special coding that needs to happen to get the sorting of colums to work. I also show how to use the pager template to do custom navigation. I have also included a simple Gridview printing example.
The data source does not support sorting with IEnumerable data. Automatic sorting is only supported with DataView, DataTable, and DataSet |
|
|
|
|
|
|
|
|
 |
|
|
|
Development patterns
|
 |
|
 |
|
| Microsoft .NET Pet Shop 4.0 Microsoft® .NET Pet Shop 4.0 is the latest in Microsoft's series of benchmark applications. The benchmark compares the performance and scalability of this .NET Web application to the performance of an equivalent, revised, and fully optimized J2EE™ application developed by the Middleware Company |
| DataObjects.NET 2.0.7 released! DataObjects.NET is an object persistence layer for .NET Framework. It dramatically decreases development time by handling persistence of your classes transparently - DataObjects.NET PetShop sample (Microsoft's .NET Pet Shop clone) contains 3 times less business and data tier code then its original exposing much more features including access control and editing support! |
| Manipulating Persistent Data An object (entity instance) is either transient or persistent with respect to a particular ISession. Newly instantiated objects are, of course, transient. The session offers services for saving (ie. persisting) transient instances:
|
| DataObjects.net Based applications Architecture overview of DataObjects.net |
| Custom Data Binding, Part 2 Summary: In part two, the custom data binding journey continues with a brief look at the role BindingList plays in allowing BindingSource to convert a single type into a list data source. We also look at situations where relying on the BindingSource isn't enough, such as sorting and searching. Such features need you to go a step further and create your own BindingList implementation with the additional support, which we also look at. To top it off, game data serialization is added to make life easier. (14 printed pages)
|
| Being Ignorant with LINQ to SQL LINQ to SQL differs from LINQ to Objects in that it is about working with objects that are persistent; in other words have a lifetime beyond the application. There are different styles to dealing with persistence; preference for one or the other is usually dependent on whether our perspective is data-centric or domain-centric.
|
| An extended library of collection classes for .NET The project was initiated by a suggestion of Peter Sestoft to further develop a library of collection
classes for the .Net platform he had developed during a stay at Microsoft Research at Cambridge.
The goal was to achieve a library of collection classes with a level of functionality like the library of
the Java platform, where the standard .Net collection classes are much more limited in range. Peter
was an active and inspiring advisor for the project, many thanks for that. |
| On the Way to Mastering ASP.NET: Introducing Custom Entity Classes Summary: There are situations for which untyped DataSets may not be the best solution for data manipulation. The goal of this guide is to explore an alternative to DataSets: custom entities and collections |
| Passing Values between ASP.NET Web Forms ASP.NET web forms provide excellent event driven programming model to developers. This does simplifies the overall design of your application but poses some problems of its own. For example, in traditional ASP you can easily pass values from one ASP page to another ASP page using POST. The same thing is not possible in ASP.NET if you want to stick to web form model (i.e. Server side form and control processing.). There are, however, some ways that can be used to overcome this situation. This article examines various possibilities to do the same. More specifically we will cover how to pass values using querystring, how to use session variables to do the same and finally how to use Server.Transfer method to do that |
|
|
|
|
|
|
|
|
 |
|
|
|
DataGrid
|
 |
|
 |
|
| Datagrid basic operations on ASP .Net Microsoft.net framework ships with many usefull controls. These controls makes the life of developer easy by providing them with the functinality they want.
Among those many controls is the DataGrid control which helps the developer to display the data on the screen in the format of an arranged table. Datagrid is one of the 3 templated controls provided by the Microsoft.net framework. The other two are DataList and the Repeator control. Many new controls are being developed everyday but their basic idea is inherited from the classic DataGrid control
|
|
|
|
|
|
|
|
|
 |
|
|
|
Communication between controls
|
 |
|
 |
|
| Running button click server side event before loading user controls (forum) i have such a problem: i have a user control and a grid in my webform. The user control gets and shows something from the db by looking at a session variable.
and the grid is creating the session. User is selecting a row and the session variable is created with the id of the selected row. After a row is selected i want to show its info in the user control by using the created session var but since the user control is loaded before by button click event it doesnt work the way i want it. I am makking a selection in the grid and nothing shows in user control, then i m making another selection and the info of the first selected row shows because user control is getting the id of previously selected row as teh session var.
|
| Authoring Custom Controls This section of the QuickStart demonstrates how advanced developers can write their own ASP.NET server controls that work within the ASP.NET page framework. By writing your own custom ASP.NET server controls, you can encapsulate custom user interface and other functionality in controls that can be reused on ASP.NET pages. The QuickStart provides an introduction to authoring custom controls through hands-on examples. For more information about control authoring, see Developing ASP.NET Server Controls in the Microsoft .NET Framework SDK documentation. |
| Who Is Looking: Building a Custom ASP.NET Control that uses Javascript, Cascading Style Sheets, and In this article, Stephen Walther shows you how to create a custom ASP.NET control that uses Javascript, Cascading Style Sheets, and Ajax to display a list of people who are looking at a web page in real time. You learn how to create the WhoIsLooking control |
|
|
|
|
|
|
|
|
 |
|
|
|
Data layers
|
 |
|
 |
|
| Building Layered Web Applications with Microsoft ASP.NET 2.0 This is part 1 of the article series "Building Layered Web Applications" that shows you how to build N-Layer applications with Microsoft ASP.NET 2.0. These articles teach you how to design, build and use custom business objects in your web application. The target audience for this series are developers that are ready to make the switch from using SqlDataSource controls to ObjectDataSource controls with custom business objects. Experience with ASP.NET 2 and C# is necessary while some knowledge about object oriented design certainly helps. The design I am going to show you in these articles is a simplified version of a design you would use in a real world application. It doesn't feature all the necessary functionality your application needs, but instead focuses on the underlying concepts.
|
| Creating a Data Access Layer There are two patterns commonly used for inserting, updating, and deleting data. The first pattern, which I'll call the database direct pattern, involves creating methods that, when invoked, issue an INSERT, UPDATE, or DELETE command to the database that operates on a single database record. Such methods are typically passed in a series of scalar values (integers, strings, Booleans, DateTimes, and so on) that correspond to the values to insert, update, or delete. For example, with this pattern for the Products table the delete method would take in an integer parameter, indicating the ProductID of the record to delete, while the insert method would take in a string for the ProductName, a decimal for the UnitPrice, an integer for the UnitsOnStock, and so on |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|