In ASP.Net 4.5, we can defer (lazy) validation of form fields by setting requestValidationMode attribute in httpRuntime section of web.Config file. By default, all the data coming through in request is subjective for validation. But if we want to defer the validation for form fields until they are accessed at runtime, we can set requestValidationMode attribute along with ValidateRequestMode to disabled for the controls of our interest.
Category: ASP.Net Webforms
ASP.NET 4.5 provides an ability to declare the data type of the data that a control is bound to throught ItemType property. When we set this property, two new typed variables are available in the scope of data-binding expressions: Item (One Way binding) and BindItem (Two Way Binding).
In previous versions, Data binding expressions are evaluated at runtime using reflection and bind data, which is not only developer nightmare but also encourages more data shaping problems.
ASP.NEt 4.5 introduces Async processing of Asynchronous HttpHandler using “HttpTaskAsyncHandler” abstract class and then override “ProcessRequestAsync”. HttpTaskAsyncHandler implements both IHttpAsyncHandler, IHttpHandler. In this new way, ASP.Net takes most of the overload of managing threads in continuing async tasks by itself.
In earlier versions of ASP.Net, there is no flexibility for uploading multiple files using FileUpload Control. But ASP.Net 4.5 enhanced traditional FileUpload Control now, through which multiple file uploads is possible with an extra attribute -AllowMultiple=”true”.
Cloud Computing is a magic term which is mostly heard in the recent past among the technical world Devs. For those who never knew what is a cloud (in technical terms), let me put a simple description – Cloud saying to a Dev “You build the app, and I will take care of production environment”, its as simple as that. Even Microsoft don’t want to let their proportion of coders go down, it immediately came up with Windows Azure, Microsoft Cloud Platform. Windows Azure consists of mainly three important parts – Windows Azure (a place to manage the hosted services), SQL Azure ( to manage the data storage to DB) and AppFabric (used to build, scale and manage Web). Essentially a dev need to get accustom with all these three parts sooner or later.
Implementing MVP Pattern using UserControls with WCF Database Operations in Entity Framework and LINQ – Part III
In this part of the tutorial, we carry on with the construction of MVP Pattern. First we start with the creation of View interfaces for the UserControls (which we created in PART II). Then we create the presenter classes, which will take the corresponding instances of views and then manipulate the view using Model classes (there by achieving code portability). Once we are done with the presenter classes, we implement the View interfaces in the codebehind of the UserControls. Finally we create a sample ASP.Net web page (typically webform), and use the UserControls for database transactions.
Implementing MVP Pattern using UserControls with WCF Database Operations in Entity Framework and LINQ – Part II
In this part of the tutorial – We first code for the CustomerService.cs by implementing ICustomerService.cs interface. We use LINQ queries to code database transactions. Then we create a host application (here it is a Console application) which operates the WCF service. Then we create a sample website for implementing MVP Pattern to access WCF. In the website, we implement some UserControls for fetching/updating/deleting records from the database.
Implementing MVP Pattern using UserControls with WCF Database Operations in Entity Framework and LINQ – PART I
First we create a database – ‘CustomersDB’ – with a table in it – ‘Customers’. This table Customers holds the basic data related to each and every customer. Then we create the entity model for this CustomersDB using ADO.Net Entity Framework. After that we create a WCF service with minimal end point configuration to access ServiceContracts which do basic database operations. Instead of coding the data access methods (of the class implementing ServiceContract) in traditional ADO.Net queries, we tend to use LINQ for the same. Once the service is ready, we host it using a Console App. With this we complete the backend of the article. Now we implement the MVP pattern for better separation of UI from its code with the help of presenter class. So we create an interface for both model and view and then implement them in their respective class. Finally we create a UI with some UserControls in it for adding/editing/deleting customers from the front end.
In the first part of this tutorial (PART I – Click Here), we uploaded files to the database in binary format using a FileUpload control. The plot behind saving files is to take the file from the FileUpload control, convert the same to the binary format, then save it to the DB. To make our accomplishment more flexible and maintainable, we use stored procedures along with custom classes for database transactions.
In this part of the tutorial, we retrieve the files (which are stored in a table of a database). For this purpose we first create a custom class which will hold the code for database transactions, then we create a generic handler which will process all the incoming requests for the downloading of files. Finally we create a web page which uses the before mentioned class and handler along with a repeater control to make the file available to the client.
In this tutorial, we first save files to the database in binary format, then in the second part of the tutorial we see how to provide a download option to the files residing in database. For uploading the files to DB, we use a FileUpload control and to provide download facility we make use of a Generic handler. The plot behind saving files is to take the file from the FileUpload control, convert the same to the binary format, then save it to the DB. To make our accomplishment more flexible and maintainable, we use stored procedures along with custom classes for database transactions. And the plot behind retrieving files is to use a handler which process the incoming request which are made to the files in database.
In this tutorial, we see how to develop a simple Contact Page webform. This Contact Page is going to be a similar one to what we usually see in our day to day experience out in internet. Here we use AJAX HTML editor to enable Html email to the owner of the website. The basic outline would be – Users provide their general details like name and email, and also they can provide Html Message (using AJAX HTML Editor) in the Contact Page, where a basic validation is done as first step. Then we take the Html string, and send the same in the email to the authorized person of the website (typically owner) using SMTP settings (System.Net.Mail namespace). For ease of use, we use Gmail SMTP settings (host and port) for sending email. For better interactivity UpdateProgress control is used to show the progress of email routine.
In this article, we see how to provide a download option (say for example to download images) to the users of our website. In accomplishing the requirement we use a Generic HttpHandler – which handles all the requests made for the download. For demonstration purpose we take some images and display them using a Datalist, in which we do provide an option to download. On download option click, the generic handler will process the request and displays an dialog in the client questioning client either to save or open the file, accordingly corresponding action will be taken place.
1) The main motive behind writing this code snippet is that this topic has been asked number of times @forums.
3) The credit of the code goes to a MSFT (I never knew his name) for providing this sample @forums.
In this tutorial, we see how to develop a simple comments section. This comments section is going to be a similar one to what we usually see in our day to day experience. Here we use TinyMCE editor to enable Html Comments. And also catpcha is enabled (with the help of reCaptcha of Google). The basic outline would be – Users provide their general details like name and email, and also they can provide Html Comment (using TinyMCE), and finally they should enter the text showed in the captcha for validating robots. Then we take the Html string, encode it using HtmlEncode(), store it in database. Finally we retrieve the encoded string from the database, we then decode it and display it in the page as Comment.
In this tutorial, I create a sample Database “Example” with a table “Images” which holds the information about images like ImageName, ImageDescription and ImagePath. Then I use a SqlDataSource in combination with Repeater to display the images from the database onto the page. Here we use LightBox plugin to open up a modalpopup window with the details of the image (shown in modalpopup) along with the flexibility of navigating between images without closing the modalpopup.
In this tutorial, I create a sample Database “Example” with a table “Images” which olds the information about images like ImageName, ImageDescription and ImagePath. Then I use a SqlDataSource in combination with Repeater to display the images from the database onto the page. Here we use GalleryView to make the slideshow of images in the repeater along with display of the particular image which is in focus.
In this tutorial, we first create a Database and store the necessary details of the Images like ImageName, ImagePath (physical directory path in relative URL), ImageDescription etc. Then we display these images on the web page using a Repeater in combination with SqlDataSource. After this we use Client CallBack to display the details of corresponding image on which mouse is hovered. CallBacks are accomplished by implementing ICallBackEventHandler.
1) The code in this tutorial demos on how to raise an event of UsercControl which is on Parent page.
2) We got a UserControl (TestUserControl.ascx), which got a button in it. On Button click, we use a delegate to call an event from the parent page.
3) Even though personally I can’t vote to this approach of linking Page to its UserControl, but its worthy to know the procedure (as some situations may demand it).
1) In this tutorial (which is PART – II), we create a small website in ASP.Net 4.0 and we shall use a WebForm (named: PubsServiceTestPage.aspx) as a client to our service (which we created in former tutorial).
2) We Use the inline model of Webform (not the codebehind model).
3) We perform the actions using our client like, Getting all the Authors and display them in the Dropdownlist for selections, Selecting a Author and display his corresponding books using a Repeater, Modify and save the book details back to database etc.
4) To test the Client, we need the service to be running in the server, that can be simply manipulated by starting another instance of VS 2010 and running (Ctrl + F5) the PubsService.svc.cs.
1) In this tutorial we create a simple WCF service which is used to retrieve and save data from Pubs Database (Microsoft sample database).
2) The service also demos on how to use EF 4.0 and LINQ against database coding, with no requirement of writing SQL queries.
3) The continuation of this tutorial shows on how to create a client (say a WebForm in a website) to utilize this service.