Click here to Skip to main content
15,125,299 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

i have a photo gallery page and when the user clicks on the thumbnail image the original image should be displayed in the modalpopup. it should also display the progress bar in the modalpopup before the original image gets loaded.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <style type="text/css">
            filter: alpha(opacity=50);
            -moz-opacity: 0.5;
            opacity: 0.5;
            width: 100%;
            background-color: #999988;
            position: absolute;
            top: 0px;
            left: 0px;
            z-index: 800;
    <form id="form1" runat="server">
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        <asp:Image runat="server" ID="image2" ImageUrl="images/small/ground_main.jpg" />
        <asp:Image runat="server" ID="image3" ImageUrl="images/small/R.C.C main.jpg" />
        <asp:Image runat="server" ID="image4" ImageUrl="images/small/rehab_main.jpg" />
        <asp:Image runat="server" ID="image5" ImageUrl="images/small/steel_main.jpg" />
        <asp:Button ID="btnPop" runat="server" Text="Button" Style="display: none" />
        <asp:Panel runat="server" ID="panel1" Style="display: none; background-color: White;">
            <div style="text-align: center; padding: 0 5px">
                <asp:Button runat="server" ID="btncancel" Text="close" /></div>
            <img id="popImg" src="" />
        <asp:ModalPopupExtender ID="modal1" runat="server" BackgroundCssClass="divModalBackground"
            TargetControlID="btnPop" PopupControlID="panel1" CancelControlID="btncancel"
            OnCancelScript="hpop()" RepositionMode="RepositionOnWindowScroll">
<script language="javascript" type="text/javascript">
    function mpop(path) {
        document.getElementById("popImg").src = path;
        return false;
    function hpop() {

and in aspx.cs file i have the following code

protected void Page_Load(object sender, EventArgs e)
    // since the original images are in the folder named "big" i'm changing the path as follows...      

        image2.Attributes.Add("onclick", "return mpop('" + image2.ImageUrl.Replace("small", "big") + "');");
        image3.Attributes.Add("onclick", "return mpop('" + image3.ImageUrl.Replace("small", "big") + "');");
        image4.Attributes.Add("onclick", "return mpop('" + image4.ImageUrl.Replace("small", "big") + "');");
        image5.Attributes.Add("onclick", "return mpop('" + image5.ImageUrl.Replace("small", "big") + "');");

// i.e the path 'images/small/ground_main.jpg' will became 'images/big/ground.main.jpg'


the images gets loaded in the modalpopup. but i want to show a progressbar inside the modalpopup before the image gets loaded.

thanks in advance.

Updated 4-Dec-10 16:59pm
[no name] 4-Dec-10 11:53am
Are you asking for assistance or for someone to do it for you? There a many, many examples of modal popups, what have you tried?
[no name] 4-Dec-10 20:21pm
Comments are not the place for a code dump. You should have edited your question to include any necessary code but it was not necessary to dump your code, it is irrelevant to the question.
Once again, there are many, many examples of modal popups and progress indicators. What have you looked at?

1 solution

Most progress indicators are simply animated gif that are shown or hidden as necessary. In your case, add the progress image to the modal popup div and handler the onload event for the downloaded image to hide it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900