473,663 Members | 2,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Object Expected error

Hello,

I am trying to replace my alert message box with a popup page.

In my page behind,

Response.Write( "<script> alert('" & MyMsg & "') </script>")

is working fine.

I created a javascript function DoDialog() in the HTML part of the same page
and tried to run it with

Response.Write( "<script language='javas cript'> doDialog() </script>")

Then I get Object Expected error. This code and the function are both on
the same page, and the name of the function is spelled out correctly. I
tried to put my function in an external file .js but the result was the same
(Object Expected).

On the other hand, when I call the same function within HTML page with
onclick="doDial og()", it works fine. If I call it from code behind page
using Button.Attribut es.Add("onclick ", "doDialog() ") it works fine too.

Why this function cannot be recognised in Response.write? In fact, I cannot
use "onclick" to call this function because I have some complex checks to do
on the code behind page (using select case, different stored procedures,
etc.) after clicking the button and before running this function.

Jan 6 '06 #1
4 2357
javascript is case sensitive. If the function is called DoDialog, that is
how you have to call it.

Also, if the code to run the function is streamed out before the function
itself, then the engine will not be able to find the function. But you
didn't post your page code, so it's really just a guess.

"Kiyomi" <k.*******@unes co.org> wrote in message
news:e5******** *****@TK2MSFTNG P10.phx.gbl...
Hello,

I am trying to replace my alert message box with a popup page.

In my page behind,

Response.Write( "<script> alert('" & MyMsg & "') </script>")

is working fine.

I created a javascript function DoDialog() in the HTML part of the same
page
and tried to run it with

Response.Write( "<script language='javas cript'> doDialog() </script>")

Then I get Object Expected error. This code and the function are both on
the same page, and the name of the function is spelled out correctly. I
tried to put my function in an external file .js but the result was the
same
(Object Expected).

On the other hand, when I call the same function within HTML page with
onclick="doDial og()", it works fine. If I call it from code behind page
using Button.Attribut es.Add("onclick ", "doDialog() ") it works fine too.

Why this function cannot be recognised in Response.write? In fact, I
cannot
use "onclick" to call this function because I have some complex checks to
do
on the code behind page (using select case, different stored procedures,
etc.) after clicking the button and before running this function.

Jan 6 '06 #2
Here is my HTML page. I would very much appreciate your advice.
<input onclick="doDial og()" > works well, but this is not really what I
really need.
I wish to call doDialog() from different places in the code behind page, for
example, using Response.Write( "<script language='javas cript'> doDialog()
</script>")

Thank you.

<HTML>
<HEAD>
<SCRIPT language="javas cript">
function doDialog()
{if (Form1.textErro r.value != "")
{
var x=showModalDial og('dcontents.h tm', Form1.txtError. value,
'status:no;resi zable:yes');
d1.innerHTML="T he dialog box return value was: " + x;
}
}
</SCRIPT>
</HEAD>

<body>
<form id="Form1" method="post" runat="server">
<P>Enter your age :
<asp:textbox id="txtInput" runat="server"> </asp:txtbox></P>
<P>
<asp:button id="Button2" runat="server"
Text="OK"></asp:button></P>
<P>
<asp:label id="lblError runat="server"
ForeColor="Red" ></asp:label></P>
<asp:label id="lblConfirm runat="server"
ForeColor="Gree n"></asp:label></P>
<P>
<asp:rextbox id="txtError runat="server"> </asp:textbox></P>
<P>
<input onclick="doDial og()" type="button" value="Create
Dialog"></P>
<DIV id=d1></DIV>
</form>
</body>
</HTML>

"Marina" <so*****@nospam .com> wrote in message
news:uB******** ******@TK2MSFTN GP11.phx.gbl...
javascript is case sensitive. If the function is called DoDialog, that is
how you have to call it.

Also, if the code to run the function is streamed out before the function
itself, then the engine will not be able to find the function. But you
didn't post your page code, so it's really just a guess.

"Kiyomi" <k.*******@unes co.org> wrote in message
news:e5******** *****@TK2MSFTNG P10.phx.gbl...
Hello,

I am trying to replace my alert message box with a popup page.

In my page behind,

Response.Write( "<script> alert('" & MyMsg & "') </script>")

is working fine.

I created a javascript function DoDialog() in the HTML part of the same
page
and tried to run it with

Response.Write( "<script language='javas cript'> doDialog() </script>")

Then I get Object Expected error. This code and the function are both on the same page, and the name of the function is spelled out correctly. I
tried to put my function in an external file .js but the result was the
same
(Object Expected).

On the other hand, when I call the same function within HTML page with
onclick="doDial og()", it works fine. If I call it from code behind page
using Button.Attribut es.Add("onclick ", "doDialog() ") it works fine too.

Why this function cannot be recognised in Response.write? In fact, I
cannot
use "onclick" to call this function because I have some complex checks to do
on the code behind page (using select case, different stored procedures,
etc.) after clicking the button and before running this function.


Jan 6 '06 #3
You showed the source code for your page - but not the page as it is when
streamed down as HTML.

Your Response.Write is writing out the call to doDialog at the very top of
the page. The function does not get declared until the <head> element. So
the problem is that you are trying to call a function that javascript does
not know about yet (this is what I suggested in the first post). I suspect
that this is the order that everything is getting streamed out as.

In which case, don't use Response.Write to stream the script out at the very
top of the page. Embed it someplace else after the head element.

"Kiyomi" <k.*******@unes co.org> wrote in message
news:eB******** ******@TK2MSFTN GP14.phx.gbl...
Here is my HTML page. I would very much appreciate your advice.
<input onclick="doDial og()" > works well, but this is not really what I
really need.
I wish to call doDialog() from different places in the code behind page,
for
example, using Response.Write( "<script language='javas cript'> doDialog()
</script>")

Thank you.

<HTML>
<HEAD>
<SCRIPT language="javas cript">
function doDialog()
{if (Form1.textErro r.value != "")
{
var x=showModalDial og('dcontents.h tm',
Form1.txtError. value,
'status:no;resi zable:yes');
d1.innerHTML="T he dialog box return value was: " + x;
}
}
</SCRIPT>
</HEAD>

<body>
<form id="Form1" method="post" runat="server">
<P>Enter your age :
<asp:textbox id="txtInput" runat="server"> </asp:txtbox></P>
<P>
<asp:button id="Button2" runat="server"
Text="OK"></asp:button></P>
<P>
<asp:label id="lblError runat="server"
ForeColor="Red" ></asp:label></P>
<asp:label id="lblConfirm runat="server"
ForeColor="Gree n"></asp:label></P>
<P>
<asp:rextbox id="txtError runat="server"> </asp:textbox></P>
<P>
<input onclick="doDial og()" type="button" value="Create
Dialog"></P>
<DIV id=d1></DIV>
</form>
</body>
</HTML>

"Marina" <so*****@nospam .com> wrote in message
news:uB******** ******@TK2MSFTN GP11.phx.gbl...
javascript is case sensitive. If the function is called DoDialog, that is
how you have to call it.

Also, if the code to run the function is streamed out before the function
itself, then the engine will not be able to find the function. But you
didn't post your page code, so it's really just a guess.

"Kiyomi" <k.*******@unes co.org> wrote in message
news:e5******** *****@TK2MSFTNG P10.phx.gbl...
> Hello,
>
>
>
> I am trying to replace my alert message box with a popup page.
>
>
>
> In my page behind,
>
> Response.Write( "<script> alert('" & MyMsg & "') </script>")
>
> is working fine.
>
>
>
> I created a javascript function DoDialog() in the HTML part of the same
> page
> and tried to run it with
>
> Response.Write( "<script language='javas cript'> doDialog() </script>")
>
>
>
> Then I get Object Expected error. This code and the function are both on > the same page, and the name of the function is spelled out correctly.
> I
> tried to put my function in an external file .js but the result was the
> same
> (Object Expected).
>
>
>
> On the other hand, when I call the same function within HTML page with
> onclick="doDial og()", it works fine. If I call it from code behind
> page
> using Button.Attribut es.Add("onclick ", "doDialog() ") it works fine too.
>
>
>
> Why this function cannot be recognised in Response.write? In fact, I
> cannot
> use "onclick" to call this function because I have some complex checks to > do
> on the code behind page (using select case, different stored
> procedures,
> etc.) after clicking the button and before running this function.
>
>
>



Jan 6 '06 #4
Thank you very much, Marina, for your advice.
I managed to make my popup work, using RegisterStartup Script as follows.
Now, I wish to retrieve user's response (OK or Cancel) and, depending on the
response, I wish to continue different processes.
Would you please advice me how I can do this ?

Thank you very much.
************* HTML page *************

function doConfirm(msg) {
var x=showModalDial og('Confirm.htm ', msg, 'status:no;resi zable:yes');
}
************* VB code behind page *************

Function CheckRules()

Dim msg as String
msg = "An error is detected. Do you want to continue processing ? "

If (Not Me.IsStartupScr iptRegistered(" Startup")) Then
Me.RegisterStar tupScript("Star tup", "<script>doConf irm('" & msg &
"');</script>")
End If

----- After running doConfirm(msg), this is what I wish to do --------

If doConfirm(msg) returns True (i.e., user clicks OK button)
Continue processing below
Else (i.e., user clicks Cancel button)
Return False
Exit Function
End if

----- Continue processing

Return True

End Function
"Marina" <so*****@nospam .com> wrote in message
news:uc******** *****@TK2MSFTNG P12.phx.gbl...
You showed the source code for your page - but not the page as it is when
streamed down as HTML.

Your Response.Write is writing out the call to doDialog at the very top of
the page. The function does not get declared until the <head> element. So
the problem is that you are trying to call a function that javascript does
not know about yet (this is what I suggested in the first post). I suspect that this is the order that everything is getting streamed out as.

In which case, don't use Response.Write to stream the script out at the very top of the page. Embed it someplace else after the head element.

"Kiyomi" <k.*******@unes co.org> wrote in message
news:eB******** ******@TK2MSFTN GP14.phx.gbl...
Here is my HTML page. I would very much appreciate your advice.
<input onclick="doDial og()" > works well, but this is not really what I
really need.
I wish to call doDialog() from different places in the code behind page,
for
example, using Response.Write( "<script language='javas cript'> doDialog()
</script>")

Thank you.

<HTML>
<HEAD>
<SCRIPT language="javas cript">
function doDialog()
{if (Form1.textErro r.value != "")
{
var x=showModalDial og('dcontents.h tm',
Form1.txtError. value,
'status:no;resi zable:yes');
d1.innerHTML="T he dialog box return value was: " + x;
}
}
</SCRIPT>
</HEAD>

<body>
<form id="Form1" method="post" runat="server">
<P>Enter your age :
<asp:textbox id="txtInput" runat="server"> </asp:txtbox></P>
<P>
<asp:button id="Button2" runat="server"
Text="OK"></asp:button></P>
<P>
<asp:label id="lblError runat="server"
ForeColor="Red" ></asp:label></P>
<asp:label id="lblConfirm runat="server"
ForeColor="Gree n"></asp:label></P>
<P>
<asp:rextbox id="txtError runat="server"> </asp:textbox></P>
<P>
<input onclick="doDial og()" type="button" value="Create
Dialog"></P>
<DIV id=d1></DIV>
</form>
</body>
</HTML>

"Marina" <so*****@nospam .com> wrote in message
news:uB******** ******@TK2MSFTN GP11.phx.gbl...
javascript is case sensitive. If the function is called DoDialog, that is how you have to call it.

Also, if the code to run the function is streamed out before the function itself, then the engine will not be able to find the function. But you
didn't post your page code, so it's really just a guess.

"Kiyomi" <k.*******@unes co.org> wrote in message
news:e5******** *****@TK2MSFTNG P10.phx.gbl...
> Hello,
>
>
>
> I am trying to replace my alert message box with a popup page.
>
>
>
> In my page behind,
>
> Response.Write( "<script> alert('" & MyMsg & "') </script>")
>
> is working fine.
>
>
>
> I created a javascript function DoDialog() in the HTML part of the same > page
> and tried to run it with
>
> Response.Write( "<script language='javas cript'> doDialog() </script>")
>
>
>
> Then I get Object Expected error. This code and the function are both
on
> the same page, and the name of the function is spelled out correctly.
> I
> tried to put my function in an external file .js but the result was
the > same
> (Object Expected).
>
>
>
> On the other hand, when I call the same function within HTML page with > onclick="doDial og()", it works fine. If I call it from code behind
> page
> using Button.Attribut es.Add("onclick ", "doDialog() ") it works fine too. >
>
>
> Why this function cannot be recognised in Response.write? In fact, I
> cannot
> use "onclick" to call this function because I have some complex

checks to
> do
> on the code behind page (using select case, different stored
> procedures,
> etc.) after clicking the button and before running this function.
>
>
>



Jan 10 '06 #5

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

Similar topics

4
44862
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) {
2
2278
by: jsnX | last post by:
i want a function object that is a) initialized with an STL container foo b) will search foo for an object of type foo::value_type here is my code: ======================================================================== /* if we have a big list of things, and we went to check it * over and over for this or that thing, then we can use this * object to cache the list and consolidate queries of it.
2
1133
by: FredC | last post by:
OS Name Microsoft Windows XP Professional Version 5.1.2600 Service Pack 2 Build 2600 Total Physical Memory 1,024.00 MB MDE 2003 Version 7.1.3008 ..NET Framework 1.1 Version 1.1.4322 SP1 Microsoft Visual C# .NET 69462-335-0000007-18707 Crystal Reports for Visual Studio .NET AAP50-GS0000S-WCK00C3
11
44231
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)
26
5668
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized several parts of the DOM, but this does not include the window object. Thank you
12
5538
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. Foo = function(type) { this.num = 0; this.type = type this.trigger(); } Foo.prototype.trigger = function() {
4
2766
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
3897
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
13301
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."
2
5724
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
8435
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
8345
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7368
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
6186
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
5655
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
4181
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...
2
1999
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1754
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.