Showing posts from March, 2013

App_Offline.htm in ASP.NET

One of the most useful features of ASP.NET is the “App_Offline.htm” . It provides a much easy way to make the ASP.NET application offline while we do our modifications on the site. How we do it? We just create a file and name it exactly  as ‘app_offline’ and place it in the root of a web application directory that we have configured within IIS., This will make the site offline, unload the application domain from the server, and stop processing any new incoming requests for that application.It will serve the contents of the app_offline.htm file in response to all new dynamic requests for the application. How we make the site online? Once we rename/remove the App_offline.htm file, the next request into the application will cause ASP.NET to load the application and app-domain again, and it will be back to normal. This feature is first introduced in ASP.NET 2.0 and it is available now in all the later versions. Just give the App_offline.htm page's content as follows.  This will be dis

Postback Issue and retrieving values - dynamic controls

In my last post “ CREATINGCONTROLS DYNAMICALLY IN ASP.NET ” I have explained about creating controls dynamically in Postback Issue Solving : By creating controls dynamically for each and every post back the controls will get cleared.  This is due to the lack of initialization of these controls.  If we initialize an server control in aspx page then there is no need of initializing this control every time, objects will be initiated while parsing the aspx page itself.  By in case of dynamically created controls there will not be any initialization in postbacks so the solution for the controls to stay at postback is – Creating the controls on page load and repeating the creation process in each and every postback.  Now after a change my cs file’s code will look like as follows     protected void Page_Load( object sender, EventArgs e)     {         if (hdfTemp.Value == "1" ) { CreateForm(); }     }     protected void btnGenerateForm_Click( o

Dynamic Controls in ASP.NET

The situation may occur that controls to be created dynamically at runtime, these controls should react for their events i.e., dynamically generated controls should be event driven.  For handling these kinds of situations this post will be very useful.  First of all we will see how to create and show controls on the form dynamically with an example.  In this example I’m creating a form with one label and one textbox aligned in a table control. In, every control can be added as a child control for other container controls like placeholder control, panel control etc.  In this way here also we will create controls and add those controls to one of the parent controls. Create a place holder control which will hold our dynamically created controls. Create a button in which on this button click we are creating and showing controls on the page.   The code which I have written in aspx page will be as follows. < asp : Button ID ="btnGenerateForm" runat =&q