473,772 Members | 2,564 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_DeleteCom mand(object source, DataGridCommand EventArgs e)
{
string fName, lName;
fName = e.Item.Cells[5].Text.Trim();
lName = e.Item.Cells[4].Text.Trim();
Response.Write( "<script language=javasc ript>confirmDel ete('" +
fName + "', '" + lName + "')</script>");
if (hdnDelete.Valu e == "true")
//do stuff
}
confirmDelete() looks like this...

function confirmDelete(f Name, lName)
{
if(confirm('Del ete ' + 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 5807
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.javas cript 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(f Name, lName)
{
if(confirm('Del ete ' + 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.javas cript 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.javas cript 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
44876
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 follows: myFunction(k) {
1
2286
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 "Object Expected" error on the alert statement. The same code doesn't give an error in NN or Opera or Mozilla or FireFox. Can someone give me a clue as what could be wrong here?
3
2384
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 validatePage() { // select the items in the TeamDivisions listbox var i=document.TeamMaintenance.TeamDivisions.options.length -1 For (i; i>=0; i--)
11
44258
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 Console, and it comes back with no errors. Any pointers on this, would be much appreciated. <script type="text/javascript"> <!-- var p = new Array(0,0,0,0,0) var c = new Array(0,0,0,0,0,0,0,0,0)
4
3153
by: Kiyomi | last post by:
Hello, I am trying to replace my alert message box with a popup page. In my page behind,
4
2784
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 class="headerBG_2"></div> <div class="contentBG_2"> <!-- flash banner --> <div class="flash_banner"> LINE 66 <script type="text/javascript">
1
3916
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 Javscript issue. but how do we, mere mortals who know nothing of anything about Java, scripts, etc, fix this? Is there a programm, does MS have any fix? is there any tweak like in the Registry, or whatever, how do I access anyihint java without in IE 7...
10
13323
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." "Line:xxx" "Error: Object expected" and Debug says: "Microsoft JScript runtime error: Object expected."
4
27194
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 correctly or it open but with error on page. I double click on the explamation mark, they said "object expected" in different line but the same char and code. also not only object expected I face, there is also "unterminated string constant" "object doesn't...
2
5744
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="<%= ViewData %>" /> -
0
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9914
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7461
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.