

The Page.IsPostBack property is true if the APS.NET page is loaded in response to a client postback otherwise, it’s false. In this example, it’s important to know if the page was posted back or not, because we want to generate a dynamic image only when the user clicks on the submit button - not when he of she first loads the page. Within this sub-routine, you can check to see whether the request for the page was generated via a data postback (the user clicked on the submit button, for example), whether the user came to this page from another page, or whether the user simply typed the page URL into the browser’s address bar. Here’s the code that displays these form elements: Įvery time you request an ASP.NET page, the Page_Load event is triggered on the server and the Page_Load sub-routine is called. The text box will receive the text that will be displayed on the image, and the button will generate the image.

The first dropdown box allows us to choose the background color of our image, while the second allows us to select a font. To demonstrate simple dynamic ASP.NET image generation, we’ll create an ASP.NET Web page with two dropdown boxes, one text box, and a button. NET classes located in the System.Drawing namespace to illustrate how to create images on the fly with ASP.NET. Generate images with random text (access code) for use with your user registration pages to prevent automated registrations.Create dynamic charts based on dynamic user input or database data.Generate a thumbnail gallery from your full-size gallery images.Now, for the inevitable question: why would you need to generate images on the fly for your ASP.NET Web pages? Here are several practical applications of dynamic image generation: ASP.NET developers can use these classes to draw various shapes, create text, and generate images in many different formats, including GIF, JPEG, PNG, etc.

NET Framework offers several classes for image generation and manipulation. Various image manipulation capabilities are now built directly into the. Fortunately, with ASP.NET, those days are over. With classic ASP, developers were forced to use third-party components like ASPImage and ASPPicture for dynamic image manipulation. NET framework make the task of generating images on the fly very easy.
