ASP.NET

Topics related to ASP.NET:

Getting started with ASP.NET

ASP.NET is a collection of technologies within the .NET Framework that are targeted towards web application development. These technologies consist of:

  • WebForms: A RAD style development platform using web controls.
  • MVC: A Model View Controller development platform.
  • SignalR: A real-time messaging platform for client/server messaging.
  • Razor: A front-end markup language you can embed server-side commands with.
  • WebAPI: A platform for building REST API style applications.

Page Methods

More than one parameter

In the example the C# function just request one parameter, if you need to pass more than one you can do it, just put them in order in your JS call and you are good to go. Ej.

//C#
public static int SumValues(int num1, int num2, int num3, ..., int numN)

//JS
PageMethods.SumValues(num1, num2, num3, ..., numN, onSuccess, onError);

Return value

In the onSuccess function the result is going to be the C# function's return value. In the onError function the result is going to be the error.

GridView

Data Binding

Directives

Event Handling

Repeater

httpHandlers

Session State

HTTP is stateless. ASP.NET session state is a framework that facilitates maintaining state between HTTP page requests.

Session differs from the class level variables in its ability to remain available across post-backs and different pages. For instance, a session variable created in Page1.aspx will be available if the user is redirected to Page2.aspx afterwards, within the same application.

Also, in contrast to static variables declared at the page level, the session variables are independent for different users. Meaning, changing the value of one user's session variable will not affect the value of the same variable for other users.

While ViewState can be used to store user's data temporarily, it doesn't allow saving data across multiple pages. In addition, the viewstate is part of the page and is sent to the client. As a result, any critical information related to the user cannot be saved in the ViewState, and that's where Session variables become useful.

Session Managment

Page Life Cycle

WebForms

All ASP.Net WebForm controls require runat="server" in order to communicate with the CodeBehind.

DayPilot Scheduler

This is basics of DayPilot schedular which needs to be further explore.

ASP.NET - Validators

ASP.NET - Managing State

Expressions

ASP.NET - Basic Controls

Middleware

The AppFunc type is just an alias for Func<IDictionary<string, object>, Task> type to shorten method signatures, much like typedef in C++.

ASP.NET - User Controls

Find Control by ID

  • FindControl is not recursive, it only searches through immediate children of the control
  • There is an overload FindControl(String, int) which is not indented for public usage
  • If nothing is found, FindControl returns null, so this is often a good idea to verify result for being not null

Event Delegation

I haven't found any disadvantages in this approach but there are a few things which make this a little problematic.

  1. You need to add an event handler for each and every event. If you do not add the event handlers in the OnInit event of the page, you might face some problems that on page post back, you will lose the event assignment (as ASP.NET is stateless, which is not the case with Windows controls).
  2. In this approach, you need to respect the page life cycle events. Some times when you are working on the Designer, there might be a case when the event handler gets lost without your notice.
  3. Even if you have not added the event handler, you will not get any errors or warnings. If you have multiple pages for performing the same action, there is no guarantee that all the method names will be same; the developer can choose their own method names, which reduces the maintainability of the code.

Data List

Asp.net Ajax Controls

View State

Katana

WebService without Visual Studio

In a separate StackOverflow Documentation post, we'll look at consuming this Calculator WebService.

Asp Web Forms Identity

ASP.NET Caching

UpdatePanel

A ScriptManager must be added to page to make the UpdatePanel to work.

ScriptManager

web.config > system.webServer/httpErrors & system.web/customErrors sections