Microsoft JScript runtime error: 'document.body' is null or not an object

November 20, 2008 13:07 by RampidByter

I was working on a project recently working on the master page of a .Net 2.0 Web Application and I encountered the most ambiguous error message. I was removing style sheet controls that were going to be added to a dynamic Page style mechanism when I first ran into the error. I had been going through the tags removing the trailing ASP control tags with the /> tag to end the control markup.

I did this on a JavaScript tag changing from this:

<script type="text/javascript" language="javascript" src="../scripts/vkboards.js”></script>

To this:

<script type="text/javascript" language="javascript" src="../scripts/vkboards.js"/>

Everything compiled fine but when I ran the project I kept getting this error message:

Microsoft JScript runtime error: 'document.body' is null or not an object.

Code Segment:

var _b=document.createElement("div");

var _c=document.createElement("div");

_b.style.visibility="hidden";

_b.style.position="absolute";

_b.style.fontSize="1px";

_c.style.height="0px";

_c.style.overflow="hidden";

document.body.appendChild(_b).appendChild(_c);

It was really strange and i took a look again at my code and the only thing I could think was that all the JavaScript included file gets inserted on the page rendering in-between where the beginning script markup and the end tag markup is located. I didn’t see this happening on the page markup when the exception was thrown, but that’s my best guess for now. If you’ve run into this error it’s easy enough to fix just add an ending tag, </script> in this case, and the exception will be diverted.


Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

IM A PC . . . 2

October 18, 2008 06:01 by RampidByter

So recently a friend and I were going to lunch, we work together, and after leaving the building I notice the bosses Lotus sitting there with a custom plate. I remember thinking about how it’d be cool if I had a license plate that says “IM A PC.” I guess one man's opinion about what is considered cool can vary person to person. So, being myself, I just randomly say aloud that I’d like to get a license plate that says “IM A PC” to my colleague. The next thing I know he turns around with a spark in his eyes and says ‘that’s genius!’ Not sure whether he was in fact joking at my expense until we got to the car, and he was still carrying on about it. The more I thought about it the more I wanted the plate and we agreed to check after lunch.

So we get back to the office and check the custom plates office. ‘I AM A PC’ was available and that’s when my friend said if I wasn’t going to order it he would. So I owed him some tithe for a few things he’s done to help my life out from in-the-door tech job to my current position. So i said sure go ahead, and at the same time I had another thought. “IM A PC 2” so I could state that I am in fact a PC too. So I checked, and what do you know it’s completely available.

At this point I had a dilemma I let my buddy register the main one or I register it. So I decided to let him have first dibs, he ordered, and now of course I have to order mine. I proudly sit here today with the new plates “IM A PC 2” and he has “I AM A PC.” Yesterday we parked the vehicles next to each other, and it was the funniest geekiest thing I’ve ever seen. I felt proud of my new plates, and we, to me, exemplify the true meaning of the Microsoft Ad CampaignIM A PC.” We're going to get together soon for our official I'M A PC photo that we're going to submit to Microsoft. I'm totally going to wear my .Net shirt.



Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

ASP.Net Gridview using JavaScript Confirm("") dialog

October 15, 2008 11:38 by RampidByter

I inherited an ASP.Net 2.0 web application project that was in desperate need of repair. One thing I quickly noticed was the amount of JavaScript scripts that were added on the Page_Load to the click event of LinkButton controls within a template column in a GridView control.

The scripts would add the JavaScript Confirm(“”) function to the click event of each control to prompt a user with a hard-coded message on whether to continue the action or cancel. The problem with this approach was that on clicking cancel the post-back would still occur and as a result the delete/edit/insert action would be performed. After spending what seemed like days trying to find the cause of the post-back and why even though the JavaScript function returned the value to the client click it would still carry on it’s server side action.

I searched and searched on the cause of this problem and found everything from creating a page level script to change the 0 and 1 to the respective true and false values that get returned from the JavaScript call. This did the exact same thing as just returning 1 or 0 based on the Ok or Cancel button selection. Nothing seemed to work and the grid wasn’t setup in any special way. That was until I found the ConfirmButtonExtender control as part of the AJAXToolkit.

After including a ConfirmButtonExtender within the template column with the control to validate set to my LinkButton did the JavaScript confirm dialog actually do what it was supposed to. Now when clicking on a LinkButton the confirm dialog appears, displays my ConfirmText property, and then based on the user action of clicking Ok or Cancel will actually stop the post-back from happening. Fantastic, the exact fix I was looking for, and it had the added advantage of exposing a control on the code-behind that could have the displayed confirmation text easily changed without having to consciously worry about JavaScript hooks to the client click event.

Now all I have to do is add my ConfirmButtonExtender to my TemplateField as such:

<asp:TemplateField HeaderText="Delete">
<ItemTemplate>                           
<asp:LinkButton ID="lbtndelete" runat="server" CommandName="Delete" Text="Delete" />
                           
<ajaxToolKit:ConfirmButtonExtender ID="cbeDelete" runat="server" TargetControlID="lbtndelete" />
                       
</ItemTemplate>
</asp:TemplateField>

On the GridView I can simply add an event handler for the OnRowDataBound event to programmatically assign my ConfirmText from say a Resource file or possibly other mechanism.

OnRowDataBound="GrvAdmin_RowDataBound"

protected void GrvAdmin_RowDataBound(object sender, GridViewRowEventArgs e)       
{
           
((AjaxControlToolkit.ConfirmButtonExtender)e.Row.FindControl("cbeDelete")).ConfirmText = Resources.Resource.CONFIRM_DELETE_USER;
}


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Pre-marital Counseling – Reprogramming ones subconscious

October 12, 2008 06:35 by RampidByter

To get up to speed on current events I’m getting married in about two weeks. Not that far away, but I have been wanting pre-marriage counseling for some time to make sure things are on pace beforehand. Just like everything else in my life I wait near the last minute on this as well, but last night was our first marriage counseling session with the preacher that was hired to perform the ceremony. I was a bit anxious to go and a little nervous because I had no idea what to expect. I’ve heard a few things about how it goes from my cousin whom took part in a catholic pre-marriage requirement for their wedding, and from a few misc people who are actively involved in these matters.

So we head downtown last night with the appointment at the preachers home down off Hamilton avenue, which is in or near what I’d call the ‘ghetto’ of the Cincinnati area. A little nerve wrecking going down there so late at night in areas crawling with homeless naredowells in an area I’d prefer to avoid. I felt a bit uneasy going in the first place but was reassured by my fiancé that the preacher was a funny guy and that it would be a helpful experience. We reached his home about 8:17pm and from that point things took a spiral quickly.

Walking up to the building a sign planted outside said ‘heated by corn’ in front of a home, and it was a little.. um, run-down? Walking in there was cement blocks lined up against a wall, possibly load bearing, and the house was old with the feeling of crumbling. It was warm though so I’ll give the corn credit. The preacher struck me as uncomfortable, yes, that’s what I’ll say was my first feeling of him. One of those guys, oh, reminds me of the preacher from poltergeist the movie who died with all the people in the cave, but decided to haunt the home built upon it. I mean he was nice, don’t get me wrong, but there was something very strange to me.

We went into the backroom of his home where there were several chairs of all assortments, in varying states of conditions, aligned in a circle in a strangely arranged room. I sat in the chair closest to the door while Steph sat to my right and the preacher sat directly in front of us probably three feet in front. He started to say things about how he’s hoping we’re not as broken up as everyone else that has been coming to him for help regarding marriages completely out of order, or about economy related problems. I said we didn’t have any major issues, and especially not about the economy so he was a little relieved, at least he said he was.

So I started things off by telling him why we were there, to understand what is coming soon, and that we’ve had issues with my not being available all the time due to work. I told him that I work many hours both at my full-time job and my other somewhat full-time job in the evenings, and how she’s not very supportive at all to anything related to what I work on. I mentioned how when I told her in front of my friends at a game night that I was going to quit my job she went totally blank faced, didn’t respond to anything, and was in general completely and utterly pissed off. It really made me irritated because I’d been telling her for weeks that I was going to quit the job at some point when I could. Then when the opportunity presented itself I left without question and she was not able to process change, even though I told her about it ahead of time, and it really set an example for me on what to expect from her.

She shared her thoughts on the subject and the preacher was just listening and interjecting with stories about his wife and their situation to give somewhat of a way to relate. From there I moved on to talking about how I can handle chaotic change and Steph cannot handle change at all. In fact I mentioned that she was unable to handle anything that didn’t have the express approval of her parents, which is still a subject of much problems between us. At that point the preacher started saying ‘we can work with that’ and started to question Steph about the validity of that argument, and I interjected to say she couldn’t even handle the thought of her parents moving away soon without problem. So he asked her about it and within one minute the water works started because she’s still emotionally attached to an invisible umbilical cord.

This is where things got very interesting. The preacher wheeled over right next to her on her right side. He then began asking her for permission to do something. He asked her several times whether she wanted to know ahead of time what he was going to do and expect or whether he could start without her knowing. At this point I’m beyond uncomfortable and wanting to head out of this place ASAP. She said she wanted to know, and so the preacher said he was going to enter into her subconscious and reprogram her to give her subconscious the ability to move on. So he kept asking if it was alright to start, and she gave im ‘permission’.

Next thing I know he has his hand on her shoulder, has her lift her arm straight out, and has his finger pushed down on her wrist. At this point he begins saying “I’m communicating with the past, present, and future lives of”, he stops to ask her name because he’s forgotten, and then continues “lives of stephanie.” Then he goes “if you can understand me give me a sign in the form of moving your arm” at this point he pushes down on her arm, which doesn’t go down very far. “Good, they want to work with me” he exclaims as if the subconscious is now working with him.

He then goes into some tirade about going to repair her subconscious, and begins to ask her subconscious questions, and to my amazement it starts responding to him by making her arm push down really far when it says no. Apparently he’s not pushing any harder, he tells us, and that it only feels that way because the subconscious is workings against Steph to let her know its upset. He begins asking her subconscious different questions and then has her cross her legs right over left. Asks her subconscious whether that is ok, it says no, and he has her cross her legs left over right. At this point the subconscious is accepting, and so he has her cross her arms right over left, and to hold her hands together with her arms still out straight. He asks the subconscious whether it’s ok, nope it’s not, and so she had to cross her arms again left over right, and what do you know the subconscious is liking that.

He then begins by having Steph chant that she is able to accept her family moving, and has her do that like 20 something with her eyes closed, and with her legs and arms crossed. When she is done he has her take her uncrossed arms, form her hands into a circle, and she was told to have her subconscious put all the negative energy into the center of the circle, and asked her to blow that negative energy out into the world. So she forms the circle, sits there, and then blows into her hands, and what do you know all that energy flew right the heck out of her! She’s now had her subconscious reprogrammed and he’s given it the power to cope with her emotional problems. From this point on she’s a new woman!

Unfortunately this whole time I’ve had to fain amazement at the miraculous abilities of the preacher to heal her subconscious and to remove all those negative feelings. I’m sitting there staring in disbelief that this is going on, and several times looked around for cameras. If I could make people do this crap I’d be videotaping it for later so I could laugh my butt off on people believing it.

That’s when it happens. He looks at me and goes “I hear you’ve been having a hard time accepting change.” I look back and go “Nope, I’m good.” The preacher goes “I’m not so sure of that.” And say again “Nope, I’m good, I like change.”

He wheels over to me and asks me whether he can talk to my subconscious to see if that’s true. Considering Steph just went through this craziness I’d cut her a break by at least pretending to go along with it. So I said “knock yourself out” and he has me lift my arm. He starts asking my subconscious to give him a sign all the while he’s got his finger on my wrist. My subconscious must have been a jerk because mine was not really giving good signals, I think because I was pushing up pretty hard, and again he emphasized he wasn’t pushing harder it was my subconscious making it feel that way. His finger looked pretty bent pushing down that hard but it made him work for his answers.

He started asking my subconscious question, I wish for the life of me I still recall what was asked, but it kept responding by pushing down far, or remaining straight out. Eventually I had to cross my arms, cross my hands, cross my legs, and then chant “I will accept change” 20 times with my eyes shut. At this point I’m completely uncomfortable, especially with my eyes shut, and in the end I was asked to make a circle as best as I could with my hands. I formed mine into a square with two L shaped sides. I was then supposed to take this new programming and place it somewhere on my body where it could start reprogramming my subconscious to accept change. I put the square on my forehead and wow what do you know I got reprogrammed! The preacher then said he gave my subconscious new programs to run and of all things compared it to him upgrading me from windows 3.1 to windows 95. I just had a lot of reprogramming that will take a little while to take hold, and it may be a little difficult but I should be more accepting to change. He said it takes a while for the subconscious programming to take effect so I will notice it gradually.

Keep in mind this whole ordeal probably took about 15 to 20 minutes tops so I couldn’t have been happier of that fact. The worst part about it was the best advice the guy gave was after the shenanigans of reprogramming and communicating with our past lives to mentioning love languages as an aside that he wanted to find out about us in five days when we’re supposed to come back to report on the progress of our reprogramming. Apparently I may have to reboot during that time I guess? Maybe I need a good defrag, and he’s my spiritual tech support preacher. My god what an experience, and thus ended my first and probably last pre-marital counseling session. Long story short he’s not the preacher anymore.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Clarity

October 2, 2008 13:13 by RampidByter

Life has been very hectic as of late. I have gained a few new clients, working on some rather large projects, and my personal life has been in super overdrive. By super overdrive I mean trying to manage buying a house, working two full-time jobs, and getting married at the end of this month.

I’ve always been telling myself that after college things would get back to normal, and that I’d be able to do those things I love doing. It’s been several months, one knee surgery, lots of little things coming up, and I’ve still not found the time to relax to do the little things. I bought the xbox 360 years ago and I’ve still not beaten Halo 3 the sole reason I bought the xbox, and there among the dust sits many other terrific games untouched. I haven’t finished Half-life 2 the game I waited months, nearly a year, just to even smell the CD box cover. I haven’t beaten it.

I have been a sampler of life for years, never digesting anything, but merely nibbling off pieces here and there just for taste. I have sunk my teeth into a new house, new life, new jobs, and I’m finding that because of the chaos i have lost clairty. I guess that comes with getting two degrees, moving to senior positions in less than 2 years out of school, and getting to the point of getting married has left my life erratic. So erratic that I’ve lost the clarity of thought because the moment I have time to think I have to start working on something else equally important for a client or friend.

So I’ve decided that everyday I’m going to work on myself. I’m going to concentrate more on concentrating on topics or subjects longer than has been the trend. I still must keep with the obligation to clients over gaming for instance, but the matter at hand is working on clarity of thought. Life is far too short and too complex to spend my days wondering where time has gone or overlooking the ability to take those extra moments just because they’re there. I will be working on clarity, something we all need, but seldom do we seek it.


Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5