473,394 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Object Expected???

I have a javascript function defined in my <headtag on my ASP.NET
page. In the code-behind i have the lines...

void pGrid_DeleteCommand(object source, DataGridCommandEventArgs e)
{
string fName, lName;
fName = e.Item.Cells[5].Text.Trim();
lName = e.Item.Cells[4].Text.Trim();
Response.Write("<script language=javascript>confirmDelete('" +
fName + "', '" + lName + "')</script>");
if (hdnDelete.Value == "true")
//do stuff
}
confirmDelete() looks like this...

function confirmDelete(fName, lName)
{
if(confirm('Delete ' + fName + ' ' + lName + '?'))
{
document.form1.hdnDelete.Value = 'true';
alert(document.form1.hdnDelete.Value); //returns 'true'
like its suppose to.
}
else
{
document.form1.hdnDelete.Value = 'false';
}
}

However, whenever i trigger the event that holds the Response.Write(),
i get the "Object Expected" error.
Any help?

Aug 11 '06 #1
5 5800
JLuv said the following on 8/11/2006 3:09 PM:
I have a javascript function defined in my <headtag on my ASP.NET
page. In the code-behind i have the lines...
What's in your "code-behind" is 100% totally irrelevant to debugging
client side script errors.

<--snipped a bunch of useless ASP code-->
However, whenever i trigger the event that holds the Response.Write(),
i get the "Object Expected" error.
Any help?
Post the HTML that the browser gets. You get 10-1 odds you are trying to
call your function before it gets defined:

someFunction()
function someFunction(){}

will result in an object expected error in IE.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 11 '06 #2
JLuv wrote:
I have a javascript function defined in my <headtag on my
ASP.NET page. In the code-behind i have the lines...
ASP.NET terminology has very little relation to what browsers actually
do when attempting to execute javascript.

<snip>
confirmDelete() looks like this...

function confirmDelete(fName, lName)
{
if(confirm('Delete ' + fName + ' ' + lName + '?'))
{
document.form1.hdnDelete.Value = 'true';
If this is supposed to be writing to the value property of a form
control (as appears to be the case) then in case-sensitive javascript
'Value' should be 'value'

<snip>
However, whenever i trigger the event that holds the
Response.Write(), i get the "Object Expected" error.
Any help?
Use the view-source features of the browser to examine the HTML and
javascript actually sent to the browser, and verify that the browser is
actually getting the code you think it should be being sent (though that
doesn't help much unless you know what ASP.NET should be outputting, and
..NET tends to shield its users from understanding how it actually
works).

Richard.
Aug 11 '06 #3
I just thought that where i defined and called the function in
code-behind had something to do with it.

You are right. When I look at the HTML the 1st line is the function
call and 25 lines later is the definition.

Now the question is how do I make sure that the function is called in
the correct place?
Randy Webb wrote:
JLuv said the following on 8/11/2006 3:09 PM:
I have a javascript function defined in my <headtag on my ASP.NET
page. In the code-behind i have the lines...

What's in your "code-behind" is 100% totally irrelevant to debugging
client side script errors.

<--snipped a bunch of useless ASP code-->
However, whenever i trigger the event that holds the Response.Write(),
i get the "Object Expected" error.
Any help?

Post the HTML that the browser gets. You get 10-1 odds you are trying to
call your function before it gets defined:

someFunction()
function someFunction(){}

will result in an object expected error in IE.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 11 '06 #4
JLuv said the following on 8/11/2006 5:38 PM:
I just thought that where i defined and called the function in
code-behind had something to do with it.
No. Well, it does in a way. Your code-behind is what generates what the
browser gets and since it has to be in a particular order in the
browser, then your code-behind is generating it in the wrong order.
You are right. When I look at the HTML the 1st line is the function
call and 25 lines later is the definition.
How did I guess that? <G>
Now the question is how do I make sure that the function is called in
the correct place?
About the same way you *should* reply to Usenet postings. You make sure
the call to the function is after the function declaration. Or, you use
the onload of the window to call it. Much the same way you should make
sure that what you are replying with is after what you are replying to.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Aug 11 '06 #5
On 11/08/2006 21:45, Randy Webb wrote:

[snip]
someFunction()
function someFunction(){}

will result in an object expected error in IE.
Only if the function declaration is in a separate script element that
follows the one containing the call. If both the call and the
declaration are contained in the same script element, or the declaration
appears in a preceding element, then there will be no error. MSIE would
be rather broken if that wasn't the case (yes, I know; it's broken
anyway :).

Mike
Aug 11 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Bill | last post by:
I call a function in my .js file like this: onClick="location.href='blank.html' + generateSearchStringFromForm('section')" where section is the name of my form. The function is defined as...
1
by: TAM | last post by:
Hi, I have a simple JavaScript code that ensures that all the form fields are filled and there is also a function that checks if the email is a valid address. For some reason IE is giving...
3
by: undercups | last post by:
When I run page I immediatley get "Object expected" message and the tag <body onload="setfocus()" is highlighted. The error occurs in this snippet from within the script file function...
11
by: westplastic | last post by:
This one is driving me insane. The script works perfect on Firefox, but Internet Explorer keeps complaining about "Error Object Expected" and stuff like that. I've run it through Firefox's Java...
4
by: Kiyomi | last post by:
Hello, I am trying to replace my alert message box with a popup page. In my page behind,
4
by: loserdude84 | last post by:
Hi I keep getting the good old error 'Object Expected Error' on a site I recently built. I am really struggling with this one. Object Expected Error Line 66 <div...
1
by: JOJO123 | last post by:
I got here in search of an answer to this Javascrpt question. I upgraded jave on XP Ie 7, acrobat 5.1 and suddenly can't open any pdf files on web sites using IE. I see u guys all say, this is a...
10
RMWChaos
by: RMWChaos | last post by:
WinVista/IE7 I am getting some weird errors only in IE7, but not in FF2.0.0.8 or NN9. It even happens on this website when I click "Sign In". The error is: "A Runtime Error has occurred."...
4
by: hatem0 | last post by:
Hi all I don't know if I am in the right forum, I hope that someone can help me. I am not a programer, my problem is when I open a website like facebook or howstuffworks the page don't open...
2
by: thj | last post by:
Hi. I've got this form that I'm trying to validate: <form id="periodForm" action="" method="post"> <p> Periode: <input id="startDate" name="startDate" type="text" size="7" value="<%=...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.