472,802 Members | 1,316 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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='javascript'> 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="doDialog()", it works fine. If I call it from code behind page
using Button.Attributes.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 3094
Would you be able to post the actual HTML submitted to the client when this
'Response.Write' is executed. I am interested in seeing where the actual
output exists within the HTML. You may find that you can fix this by changing
the location that your script ends up in the output HTML document.

Otherwise, you might also be able to try something like...

<script language=javascript>window.onload=doDialog();</script>

That way, this will get called by the client-side event when the page is
loaded.

Hope this helps,

-Eric
"Kiyomi" wrote:
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='javascript'> 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="doDialog()", it works fine. If I call it from code behind page
using Button.Attributes.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
Thank you, Eric.

I tried to place window.onload=doDialog(); right after </body> and it looks
working exactly as I wish.

However, I got another error Not Implemented on that line.

Here is my HTML for your reference.

Thank you again for your help,

Kiyomi

<HTML>

<HEAD>

<SCRIPT language="javascript">

function doDialog()

{if (Form1.textError.value != "")

{

var x=showModalDialog('dcontents.htm', Form1.txtError.value,
'status:no;resizable:yes');

d1.innerHTML="The 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="Green"></asp:label></P>

<P>

<asp:rextbox id="txtError runat="server"></asp:textbox></P>

<P>

<input onclick="doDialog()" type="button" value="Create
Dialog"></P>

<DIV id=d1></DIV>

</form>

</body>

</HTML>
"Eric Giles" <Er*******@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
Would you be able to post the actual HTML submitted to the client when this 'Response.Write' is executed. I am interested in seeing where the actual
output exists within the HTML. You may find that you can fix this by changing the location that your script ends up in the output HTML document.

Otherwise, you might also be able to try something like...

<script language=javascript>window.onload=doDialog();</script>

That way, this will get called by the client-side event when the page is
loaded.

Hope this helps,

-Eric
"Kiyomi" wrote:
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='javascript'> 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="doDialog()", it works fine. If I call it from code behind page
using Button.Attributes.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
There seems to be a problem with your HTML.

Check the line.

<asp:rextbox id="txtError runat="server"></asp:textbox>

Should be

<asp:textbox id="txtError" runat="server"></asp:textbox>

Perhaps it cannot find it because it is not created correctly.

Might be worth checking.

-Eric
"Kiyomi" wrote:
Thank you, Eric.

I tried to place window.onload=doDialog(); right after </body> and it looks
working exactly as I wish.

However, I got another error Not Implemented on that line.

Here is my HTML for your reference.

Thank you again for your help,

Kiyomi

<HTML>

<HEAD>

<SCRIPT language="javascript">

function doDialog()

{if (Form1.textError.value != "")

{

var x=showModalDialog('dcontents.htm', Form1.txtError.value,
'status:no;resizable:yes');

d1.innerHTML="The 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="Green"></asp:label></P>

<P>

<asp:rextbox id="txtError runat="server"></asp:textbox></P>

<P>

<input onclick="doDialog()" type="button" value="Create
Dialog"></P>

<DIV id=d1></DIV>

</form>

</body>

</HTML>
"Eric Giles" <Er*******@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
Would you be able to post the actual HTML submitted to the client when

this
'Response.Write' is executed. I am interested in seeing where the actual
output exists within the HTML. You may find that you can fix this by

changing
the location that your script ends up in the output HTML document.

Otherwise, you might also be able to try something like...

<script language=javascript>window.onload=doDialog();</script>

That way, this will get called by the client-side event when the page is
loaded.

Hope this helps,

-Eric
"Kiyomi" wrote:
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='javascript'> 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="doDialog()", it works fine. If I call it from code behind page
using Button.Attributes.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 7 '06 #4
Thank you very much, Eric, for your advice.
I managed to make my popup work, using RegisterStartupScript 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=showModalDialog('Confirm.htm', msg, 'status:no;resizable: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.IsStartupScriptRegistered("Startup")) Then

Me.RegisterStartupScript("Startup", "<script>doConfirm('" & 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


"Eric Giles" <Er*******@discussions.microsoft.com> wrote in message
news:5C**********************************@microsof t.com...
There seems to be a problem with your HTML.

Check the line.

<asp:rextbox id="txtError runat="server"></asp:textbox>

Should be

<asp:textbox id="txtError" runat="server"></asp:textbox>

Perhaps it cannot find it because it is not created correctly.

Might be worth checking.

-Eric
"Kiyomi" wrote:
Thank you, Eric.

I tried to place window.onload=doDialog(); right after </body> and it looks working exactly as I wish.

However, I got another error Not Implemented on that line.

Here is my HTML for your reference.

Thank you again for your help,

Kiyomi

<HTML>

<HEAD>

<SCRIPT language="javascript">

function doDialog()

{if (Form1.textError.value != "")

{

var x=showModalDialog('dcontents.htm', Form1.txtError.value, 'status:no;resizable:yes');

d1.innerHTML="The 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="Green"></asp:label></P>

<P>

<asp:rextbox id="txtError runat="server"></asp:textbox></P>

<P>

<input onclick="doDialog()" type="button" value="Create
Dialog"></P>

<DIV id=d1></DIV>

</form>

</body>

</HTML>
"Eric Giles" <Er*******@discussions.microsoft.com> wrote in message
news:D7**********************************@microsof t.com...
Would you be able to post the actual HTML submitted to the client when

this
'Response.Write' is executed. I am interested in seeing where the actual output exists within the HTML. You may find that you can fix this by

changing
the location that your script ends up in the output HTML document.

Otherwise, you might also be able to try something like...

<script language=javascript>window.onload=doDialog();</script>

That way, this will get called by the client-side event when the page is loaded.

Hope this helps,

-Eric
"Kiyomi" wrote:

> 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='javascript'> 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="doDialog()", it works fine. If I call it from code behind page > using Button.Attributes.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 9 '06 #5

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...
2
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: ...
2
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...
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...
26
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...
12
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. ...
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."...
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="<%=...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.