Subscribe to RSS Subscribe to Comments

The Aloysius Blog

Gray Out and Progress Spinner for ASP.Net AJAX

Problem: Got an AJAX-ey data entry screen with lots of text boxes and buttons. How to stop them from playing with stuff while you’re doing some updates behind the scenes? This will make the screen non-interactive and show a “progress spinner” while it’s doing it.

You can make a variety of “spinners” and other thingies at Create your own ajax loader icon. Save it in “images/ajax-loader.gif”.

This code is based on stuff found on the Telerik community site: “gray out” page when displaying loading panel. I just added the nifty spinner and a few tweaks to make it work with the regular ASP.NET AJAX toolkit.

Put this into your ASPX:


<ajax:ToolkitScriptManager ID="ToolkitScriptManager1"
    EnablePartialRendering="true" runat="server">
    <Scripts>
        <asp:ScriptReference Path="~/scripts/progress.js" />
    </Scripts>
</ajax:ToolkitScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        ... your page content
    </ContentTemplate>
</asp:UpdatePanel>
<img id="AjaxLoading" alt="Loading..." class="loadingPopup" src="images/ajax-loader.gif" />

Here’s the loadingPopup css class:


.loadingPopup
{
	border: 2px;
	padding: 4px;
	border-color: Black;
	position: fixed;
	top: 50%;
	left: 50%;
	visibility: hidden;
}

Save this in your project as “scripts/progress.js”:


// "Grays out" and makes the screen non-interactive when performing an update.
// To show a graphic progress "spinner" or something put it into hidden element
// id="AjaxLoading" on your page.

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

function BeginRequestHandler(sender, args) {
    showProgress();
}

function EndRequestHandler(sender, args) {
    hideProgress();
}

function showProgress() {
    grayOut(true, "");
    var spinner = $get("AjaxLoading");
    if (spinner == null) return;
    spinner.style.visibility = "visible";
}

function hideProgress() {
    grayOut(false, "");
    var spinner = $get("AjaxLoading");
    if (spinner == null) return;
    spinner.style.visibility = "hidden";
}

function grayOut(vis, options) {
    var optionsoptionsoptions = options || {};
    var zindex = options.zindex || 50;
    var opacity = options.opacity || 30;
    var opaque = (opacity / 100);
    //Setting the color
    var bgcolor = options.bgcolor || '#000000';
    var dark = document.getElementById('darkenScreenObject');
    if (!dark) {
        // The dark layer doesn't exist, it's never been created.  So we'll
        // create it here and apply some basic styles.
        tbody = document.getElementsByTagName("body")[0];
        var tnode = document.createElement('div');
        tnode.style.position = 'fixed';
        tnode.style.top = '0px';
        tnode.style.left = '0px';
        tnode.style.overflow = 'hidden';
        tnode.style.display = 'none';
        tnode.id = 'darkenScreenObject';
        tbody.appendChild(tnode);
        dark = document.getElementById('darkenScreenObject');
    }

    if (vis) {
        var pageWidth = '100%';
        var pageHeight = '100%';
        dark.style.opacity = opaque;
        dark.style.MozOpacity = opaque;
        dark.style.filter = 'alpha(opacity=' + opacity + ')';
        dark.style.zIndex = zindex;
        dark.style.backgroundColor = bgcolor;
        dark.style.width = pageWidth;
        dark.style.height = pageHeight;
        dark.style.display = 'block';
    }
    else {
        dark.style.display = 'none';
    }
}
// Needed for ScriptManager to load the js properly.
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

Bowling for Darkspawn (Dragon Age)

Shale chucks a rock into a crowd. Strike!

I love this game. Best from BioWare in a loong time.

Dragon Age: Dialog

I love the little conversations the other party members have with each other when they are bored. My (male) character is having a (gay) relationship with Zevran in the game. (Shale is the golem in the party.)

Shale: I have noticed that the painted elf seeks the attention of the Grey Warden.
Zevran: He certainly does.
Shale: (Snorts) I watched many such couplings during the time I spent immobile in Honnleath. Or should I say I was forced to watch. You do know that this usually ends in reproduction. I have seen it many times, indeed.
Zevran: Something tells me that won’t be a problem in this case. But that is not such a terrible thought. Creating a new life can be a great deal of fun.
Shale: So you say. I have no idea how a golem is created, but I doubt I shall be creating one anytime soon.
Zevran: Just as well, I imagine. Any lover of yours would no doubt be quickly reduced to a puddle of bruises.
Shale: So you see me winning the affection of another golem, do you? Most golems are slaves to whomever holds their control rod.
Zevran: Funny, it works exactly the same way for us as well.

Source: http://dragonage.wikia.com/wiki/Shale’s_Dialogue

Black demon goddess pussy

Let’s see how Google chews on that title.

Here’s another cat post about my other cat, Ixtab. She has demon eyes, as you can see in this photo.

Ixtab is the Mayan goddess of suicide, especially suicide by hanging. She would take the souls of people who hanged themselves to heaven. I named my cat after her because it’s a cool sounding name, and she’s black.

Ixtab is a weird cat. She is very “catty” — aloof, moody, downright irritable at times. But sometimes she is really sweet. I know she loves me because she always shows up at the door when I come home, and will let me pick her up for a minute and sometimes even purr.

I think she wants to go outside and explore. She loves to sit and look out windows, and if you leave a door open, she will try to escape. I got her a little kitty harness and leash so I can take her out, but I think she would prefer just to wander around on her own. I’m afraid she would get squished by a car, though. If I lived far from the road, I would probably let her out.

She used to go to the bathroom on my bed when she was upset. I think she knew it would upset me, and that’s why she did it. She hasn’t done that in the last year or so. Still, I keep the bedroom door closed when I am not in bed.

Computer programming = wizardry

Computer programmers are modern wizards. We read a lot of hefty books, write stuff in strange languages that nobody else understands, and study a science that is almost completely artificial. Here’s a side-by-side comparison.

Programmer Wizard
Computer program Spell
Programming book Spell book
Script Scroll
Command Magic word
Monitor Glowing pool
Mouse Wand

Objects found on my downstairs workbench/table.

In no particular order…

  • Several boxes and a binder of Magic: The Gathering.
  • A doumbek.
  • An AMD64 X2 4600+ CPU (in box).
  • A box of waterproof firecrackers.
  • Three empty tea tins.
  • A small basket with handles.
  • A pair of pliers.
  • A roll of dental tape.
  • A cat toy.
  • A blue Sharpie marker.
  • A couple of rubber bands.

Is this collection indicative of the owner’s personality?

January Yard Work

Today I used the wonderful “January thaw” weather we’re having — about 50 degrees and sunny out — to catch up on some yard work. I am using old moving boxes to gather up yard debris, and I filled up two of them with dead crap from the garden. Then I moved to the back yard. I gathered up a lot of dead branches. I am not sure if I want to rent a wood chipper and grind them up, or get a small chainsaw and make Pennsic firewood out of them. What do you think, Internet?

There are a few things I’ve been meaning to do back there: (1) rip out an old fence and take it to the scrap yard, (2) clear out the thirty thousand junk trees/shrubs that have been growing all around the property, and (3) transform it into my terraced dream back yard. #3 is kind of a lifetime project; and after pulling up one fence post, I determined I would need some heavy duty wire cutters to really get started on #1. So I got to work on #2. Last summer, I had been able to run over a lot of the smaller saplings with my cheapass (disposable) mower, but the remaining trees were either too thick to mow down, or blocked by trees too thick to mow down. All the vines and other shitty weeds growing around them made it hard to get in and clear everything out. (They also made it hard to work on removing the old fence.) Thus, I had decided to save the job (and the fence job) for winter. I broke out the pruners and sierra saw and got busy lumberjacking.

Here are some pictures of stuff I worked on today. The camera didn’t really pick up the fence too well, but you can see the kind of scrub trees I had to deal with.

More resolutions

  1. Learn my drum.
  2. Learn conversational Chinese.

Big Fat Scaredy Cat

This post is about my cat, Chac.  I am posting about my cat because I am an extremely boring person.

Here he is sitting outside the cat apartment:

chac

The name Chac (or Chaac) comes from the Maya god who brings clouds and rain.  I named him that because he looks like a cloud and because he pees a lot.

He is a large male cat and he is very strong.  But he has a really high pitched, girlish meow, and he will run away from anything that even thinks about startling him.

His favorite activities are chasing string, sleeping, jumping on my lap when I am trying to play video games, eating, drinking water, and peeing in his litter box.  (I never met a cat that pees as much as he does.)

I hope you all enjoyed this very boring blog post!

New year’s resolutions

  1. Blog more often — at least once a week.
  2. Get down to less than 200 lbs.  Then get a tattoo.
  3. Socialize more and make some new friends.  Maybe I’ll go back to GASP.
  4. Finish V1.0 of the “Quest” game

Next Page »

Based on FluidityTheme Redesigned by Kaushal Sheth Sponsored by Send Flowers