Finishing the Sample Application


There are only a few steps left to make your application fully functional. In this section you will add the remaining code.

The first thing you have to do is make sure ASP.NET knows about your custom module.

To activate the custom module for your application:

  1. In Solution Explorer double-click on the file web.config.

  2. Scroll to the end of the file and add the code in Figure 8.31 just before the line that reads </system.web> .

    Figure 8.31 ASP.NET reads the settings of your web.config file before starting the application. The web.config file can be used to control how ASP.NET runs your application.
     <httpModules>      <add name="Dimensions"      type="interfacesproject.custommodule,      interfacesproject"/> </httpModules> 

    That's all it takes to activate the custom module for your application. The next step is to add code to the dimensions.aspx page to make sure that the module is working.

To finish the dimensions.aspx page:

  1. Double-click on the dimensions.aspx item in the Solution Explorer.

  2. Double-click on an empty space on the form to bring up the code editor. The wizard will add a Page_Load event.

  3. Inside Page_Load add the code in Figure 8.32 . This code will display the width and the height values in two textboxes ( Figure 8.33 ).

    Figure 8.32 This code looks at the Items collection and extracts the __ClientWidth and __ClientHeight values that the custom module saved.
     private void Page_Load(object sender, System.EventArgs e) {  txtWidth.Text =   ((int)Context.Items["__ClientWidth"]).ToString();   txtHeight.Text =   ((int)Context.Items["__ClientHeight"]).ToString();  } 
    Figure 8.33. To test the custom module, resize the browser, and click the Refresh link. You should see the values of ClientWidth and ClientHeight change.

    graphics/08fig33.gif

graphics/tick.gif Tips

  • To get the full effect of the module working, resize the browser, then click the Refresh button below the textboxes. The textboxes should display the new dimensions.

  • Make sure you get a good night's sleep tonight.




C#
C# & VB.NET Conversion Pocket Reference
ISBN: 0596003196
EAN: 2147483647
Year: 2003
Pages: 198
Authors: Jose Mojica

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net