ASP.NET
  Home arrow ASP.NET arrow Page 4 - 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 - Creating the Sample .aspx Page


    (Page 4 of 5 )

    As for adding this sample required .aspx page, it is very easy. With Visual Studio 2008's built-in support for ASP.NET AJAX Extensions, you can directly add an AJAX web form, as is shown in Figure 6 below.


    Figure 6-Adding an AJAX web form in Visual Studio 2008


    As many web developers prefer to do, we have also leveraged <table> elements to lay out the page. Now, let's look at the HTML elements related definitions below:

    <form id="form1" runat="server">

    <div style="width: 761px">

    <asp:ScriptManager ID="ScriptManager1" runat="server">

    </asp:ScriptManager>

     

    <!-- create ObjectDataSource -->

    <asp:ObjectDataSource ID="odsComments" runat="server"

    DataObjectTypeName="DemoSpace.Comment"

    InsertMethod="AddComment"

    SelectMethod="GetComments"

    TypeName="DemoSpace.GuestBookDB">

    </asp:ObjectDataSource>

     

    <table>

    <tr>

    <td valign="top">

    <asp:UpdatePanel ID="upAddComment" runat="server">

    <ContentTemplate>

    <asp:FormView ID="fvAddComment" runat="server"

    DataSourceID="odsComments"

    DefaultMode="Insert" OnItemCommand="fvAddComment_ItemCommand">

    <InsertItemTemplate>

    <table style="width: 550px">

    <tr>

    <td class="commentTitle">

    <img alt="" src="imgs/Bullet01.gif" />Name:</td>

    <td>

    <asp:TextBox ID="txtName" runat="server"

    CssClass="commentNormal"

    Text='<%# Bind("Name") %>' Width="150px">

    </asp:TextBox>

    <br />

    <asp:RequiredFieldValidator ID="rfvName" runat="server"

    ErrorMessage="Please enter your name" ControlToValidate="txtName">

    </asp:RequiredFieldValidator>

    </td>

    </tr>

    <tr>

    <td class="commentTitle">

    <img src="imgs/Bullet01.gif" />Words:</td>

    <td>

    <asp:TextBox ID="txtComment" runat="server"

    Height="100px" TextMode="MultiLine" Width="300px"

    CssClass="commentNormal" Text='<%# Bind("Text") %>'>

    </asp:TextBox>

    <br />

    <asp:RequiredFieldValidator ID="rfvComment" runat="server"

    ErrorMessage="Please leave your word"

    ControlToValidate="txtComment">

    </asp:RequiredFieldValidator>

    </td>

    </tr>

    <tr>

    <td class="commentTitle">

    <img src="imgs/Bullet01.gif" />Verifying code:</td>

    <td>

    <asp:TextBox ID="txtCAPTCHA" runat="server"

    CssClass="commentNormal" Width="150px"

    MaxLength="5"></asp:TextBox>

    <br />

    <asp:RequiredFieldValidator ID="rfvCAPTCHA" runat="server"

    ErrorMessage="Please enter the verifying code"

    ControlToValidate="txtCAPTCHA">

    </asp:RequiredFieldValidator>

    </td>

    </tr>

    <tr>

    <td align="center" colspan="2">

    (Please enter the characters shown within the picture below.)<br />

    <img src="GenerateCAPTCHA.ashx" title="Verifying code" /><br />

    <img src="imgs/Hr_pen.gif" /></td>

    </tr>

    <tr>

    <td colspan="2" align="center">

    <table align="center" cellpadding="10" cellspacing="10" width="100%">

    <tr>

    <td>

    <asp:Button ID="btnSend" runat="server"

    BackColor="#C0FFFF" CommandName="Submit"

    Font-Bold="True" Font-Size="Medium" Text="Submit" /></td>

    <td>

    <asp:Button ID="btnReset" runat="server"

    CausesValidation="False" CommandName="Cancel"

    Font-Bold="True" Font-Size="Medium" ForeColor="Blue"

    Text="Clear" /></td>

    </tr>

    </table>

    </td>

    </tr>

    </table>

    </InsertItemTemplate>

    <HeaderTemplate>

    Leave Your Word

    </HeaderTemplate>

    <HeaderStyle CssClass="header" />

    </asp:FormView>

     

    <ajaxToolkit:NoBot ID="myNoBot" runat="server"

    ResponseMinimumDelaySeconds="15"

    CutoffMaximumInstances="3"

    CutoffWindowSeconds="150"

    OnGenerateChallengeAndResponse="MyChallengeResponse" />

     

     

    <asp:Label ID="lblMessage" runat="server" ForeColor="Red"></asp:Label>

    </ContentTemplate>

    </asp:UpdatePanel>

    </td>

    <td valign="top">

    <asp:UpdatePanel ID="upShowComments" runat="server"

    UpdateMode="Conditional">

    <ContentTemplate>

    <asp:DataList ID="dlComments" DataSourceID="odsComments" runat="server">

    <ItemTemplate>

    <table align="left">

    <tr>

    <td class="dlTitle">

    Name:</td>

    <td class="dlContent">

    <asp:Label ID="lblName" runat="server" Text='<%# Eval("Name") %>'></asp:Label></td>

    </tr>

    <tr>

    <td class="dlTitle">

    Word:</td>

    <td class="dlContent">

    <asp:Label ID="lblText" runat="server" Text='<%# Eval("Text") %>'></asp:Label></td>

    </tr>

    </table>

    </ItemTemplate>

    <HeaderTemplate>

    Already Left Words

    </HeaderTemplate>

    <SeparatorTemplate>

    <img src="imgs/Hr_book_pen.gif" />

    </SeparatorTemplate>

    <HeaderStyle CssClass="header" />

    <AlternatingItemStyle BackColor="#F7F7F7" />

    <ItemStyle BackColor="#E7E7FF" />

    </asp:DataList>

    </ContentTemplate>

    <Triggers>

    <asp:AsyncPostBackTrigger ControlID="fvAddComment" EventName="ItemInserted" />

    <asp:AsyncPostBackTrigger ControlID="fvAddComment" EventName="ItemCommand" />

    </Triggers>

    </asp:UpdatePanel>

    </td>

    </tr>

    </table>

    </div>

    </form>

    First, you may notice that the ASP.NET AJAX server side controls ScriptManager and UpdatePanel are employed, which nearly all ASP.NET AJAX server-centric applications must put into use. Therefore, we do not dwell upon them.

    Second, you should see that the important ASP.NET data source control ObjectDataSource appears herein. It is used to provide data for the FormView 'fvAddComment' and the DataList control 'dlComments.' This is typical ASP.NET 2.0 programming.

    In the middle of the code hides the AJAX Toolkit control NoBot (with its ID being 'myNoBot'). There are two properties, ResponseMinimumDelaySeconds and OnGenerateChallengeAndResponse, which need to be discussed. The  ResponseMinimumDelaySeconds property is set to 15 seconds, which means that within this period of time, if the "Submit" button is pressed, then the current action is suspected to be from a robot, as a result of which the submitting content is rejected and a warning message is thrown at the left bottom of the page.

    More ASP.NET Articles
    More By Xianzhong Zhu


     

    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 4 hosted by Hostway
    Stay green...Green IT