ASP.NET
  Home arrow ASP.NET arrow Page 5 - Handling Dynamic Images in ASP.NET 3.5 AJA...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Handling Dynamic Images in ASP.NET 3.5 AJAX Applications
By: Xianzhong Zhu
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-09-03

    Table of Contents:
  • Handling Dynamic Images in ASP.NET 3.5 AJAX Applications
  • Constructing an ASP.NET AJAX Styled Message Board Sample
  • About the Data Storage
  • Creating the Sample .aspx Page
  • Property Related Value

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Handling Dynamic Images in ASP.NET 3.5 AJAX Applications - Property Related Value


    (Page 5 of 5 )


    Next, let's look at the OnGenerateChallengeAndResponse property related value- a JavaScript function, as follows:

    protected void MyChallengeResponse(object sender, NoBotEventArgs e)

    {

    Panel p = new Panel();

    Random rand = new Random();


    // set the related properties for the panel

    p.ID = "panCheckNoBot";

    p.Width = rand.Next(123);

    p.Height = rand.Next(456);

    // hide Panel

    p.Style.Add(HtmlTextWriterStyle.Visibility, "hidden");

    p.Style.Add(HtmlTextWriterStyle.Position, "absolute");

    // add control Panel into the NoBot control

    ((NoBot)sender).Controls.Add(p);

    // specify the challenge and response

    e.ChallengeScript = String.Format(

    "var e = document.getElementById('{0}'); e.offsetWidth + e.offsetHeight;",

    p.ClientID);

    e.RequiredResponse = (p.Width.Value + p.Height.Value).ToString();

    }

    In this function, a <div> element with random width and height is generated and then added onto the DOM tree in the page. At the same time, the sum of the width and height is stored, and a JavaScript code snippet is written in the page. Note that this JavaScript code snippet will be invoked at the client-side running time to find the above <div> and obtain its factual sum of its width and height. In this way, when the page postback takes place, the NoBot control can compare the expected value with that fetched from the browser to judge whether the client side is a browser and further judge whether or not the action came from a robot.

    Summary

    In this two-part series, we have extensively examined the image-related issues under the ASP.NET 3.5 environment by building several simple yet typical sample applications for the corresponding image solutions. One important point you should take notice of is that nearly all the solutions are in relation to the HTTP handlers. Therefore, it is strongly suggested that you become familiar with them first before diving into any of the image-related solutions provided here.

    In the last section, we discussed how to use a custom HTTP handler in ASP.NET 3.5 environments to generate images and charts dynamically. Yet, it is noticeable that the HTTP handler is not the recommended tool for creating advanced diagrams. In fact, the HTTP handler is especially suitable to display images at the running time. To generate dynamic diagrams, the preferable solution is to seek help from the server side controls that are developed based upon the HTML <img> element.

    Feel free to have a look at the source code for these two articles:

    -DOWNLOAD SOURCE PART 2-


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

     

    ASP.NET ARTICLES

    - Developing a Mini ASP.NET AJAX Server Centri...
    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
    Stay green...Green IT