background preloader

ASP.NET

Facebook Twitter

MVC

How to query Web Controls hierarchy by using OfType() and OfTypeCascade() extension methods - MyanmarITPro - A Social Network for Myanmar IT Professionals. There are sometimes when you need to query the Web Controls hierarchy by specifying a Control type rather than Control ID in Code Behind.

How to query Web Controls hierarchy by using OfType() and OfTypeCascade() extension methods - MyanmarITPro - A Social Network for Myanmar IT Professionals

Even though it can be done easily in prototype js and jQuery selectors in client side, it is a bit tedious to do in server side. In fact, .NET extension method OfType() provides you this functionality and all you have to do is to write a single line of code: List < CheckBox > checkBoxList = Page.Controls.OfType < CheckBox > ().ToList(); Unfortunately, this method search for the specified type only at the immediate controls collection. It does not walk through all the way down to the leaf level of the entire hierarchy. List < CheckBox > controls = Page.Controls.OfTypeCascade < CheckBox > ().ToList(); if (control is T) yield return (T)control; } } 4.0 SEO features: Response.RedirectPermanent() - Gunnar Peipman's ASP.NET blog. Response.Redirect() returns 302 to browser meaning that asked resource is temporarily moved to other location.

4.0 SEO features: Response.RedirectPermanent() - Gunnar Peipman's ASP.NET blog

Permanent redirect means that browser gets 301 as response from server. In this case browser doesn’t ask the same resource from old URL anymore – it uses URL given by Location header. To illustrate difference between Response.Redirect() and Response.RedirectPermanent() let’s look at simple example. We need one usual ASP.NET Web Application with Global.asax file. In Global.asax file we have to implement BeginRequest() method. protected void Application_BeginRequest(object sender, EventArgs e)

Autenticación y autorización

Validation - how to set Page.IsValid in asp.net. Asp.net - On postback, how can I add a error message to validation summary. PRB: ThreadAbortException Occurs If You Use Response.End, Response.Redirect, or Server.Transfer. Web Deployment: Web.Config Transformation - .NET Web Development and Tools Blog. We have earlier discussed about Web Deployment and Web Packaging quite a bit, today I wanted to dive into web.config transformation.

Web Deployment: Web.Config Transformation - .NET Web Development and Tools Blog

If you would like to check out the other topics please read through the earlier blog posts below: Usually web applications go through a chain of server deployments before being finally being deployed to production environment. Some of these environments can be Developer box (Debug), QA Server, Staging/Pre-Production, Production (Release). While transitioning between these environments various settings of the web application residing in web.config file change, some of these settings can be items like application settings, connection strings, debug flags, web services end points etc.

VS10’s new web.config transformation model allows you to modify your web.config file in an automated fashion during deployment of your applications to various server environments.

AJAX

Asp.net - DropDownList "has a SelectedValue which is invalid because it does not exist in the list of items" Home: The Official Microsoft ASP.NET Site. Large file uploads in ASP.NET - Jon Galloway. Uploading files via the FileUpload control gets tricky with big files. The default maximum filesize is 4MB - this is done to prevent denial of service attacks in which an attacker submitted one or more huge files which overwhelmed server resources.

If a user uploads a file larger than 4MB, they'll get an error message: "Maximum request length exceeded. " Increasing the Maximum Upload Size The 4MB default is set in machine.config, but you can override it in you web.config. For instance, to expand the upload limit to 20MB, you'd do this: Since the maximum request size limit is there to protect your site, it's best to expand the file-size limit for specific directories rather than your entire application. What Happens When I Upload A File That's Too Big?

While expanding the upload restriction is a start, it's not a full solution for large file uploads. It gets really interesting if someone uploads a file that is too large. At Least Give Me A Warning A Better Solution: a RIA upload component.