473,387 Members | 1,882 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,387 software developers and data experts.

Getting "Microsoft JScript runtime error: Object expected"

have the following code on a page:

Expand|Select|Wrap|Line Numbers
  1.     protected void Page_Load(object sender, EventArgs e)
  2.     {
  3.         if (!IsPostBack)
  4.         {
  5.             Page.ClientScript.RegisterStartupScript(this.GetType(), "DoPreview",
  6.                     "<script language=javascript>\r\n" +
  7.                         "<!-- \r\n" +
  8.                         "function DoPreview()\r\n" +
  9.                             "{\r\n" +
  10.                                 "debugger;\r\n" +
  11.                                 "var win=null;\r\n" +
  12.                                 "var em = 'email=' + document.getElementById('ctl00_PlaceHolderMain_txtFriendsEmail').value;\r\n" +
  13.                                 "var fn = '&fname=' + document.getElementById('ctl00_PlaceHolderMain_txtFriendsFirstName').value;\r\n" +
  14.                                 "var ln = '&lname=' + document.getElementById('ctl00_PlaceHolderMain_txtFriendsLastName').value\r\n;" +
  15.                                 "var pn = '&phone=' + document.getElementById('ctl00_PlaceHolderMain_txtFriendsPhone').value;\r\n" +
  16.                                 "var a1 = '&addr1=' + document.getElementById('ctl00_PlaceHolderMain_txtFriendsAddress').value;\r\n" +
  17.                                 "var a2 = '&addr2=' + document.getElementById('ctl00_PlaceHolderMain_txtFriendsAddress2').value;\r\n" +
  18.                                 "var ct = '&city=' + document.getElementById('ctl00_PlaceHolderMain_txtFriendsCity').value;\r\n" +
  19.                                 "var st = '&state=' + document.getElementById('ctl00_PlaceHolderMain_txtFriendsState').value;\r\n" +
  20.                                 "var zp = '&zip=' + document.getElementById('ctl00_PlaceHolderMain_txtFriendsZipCode').value;\r\n" +
  21.                                 "var cy = '&cntry=' + document.getElementById('ctl00_PlaceHolderMain_txtFriendsCountry').value;\r\n" +
  22.                                 "var pm = '&pmsg=' + document.getElementById('ctl00_PlaceHolderMain_txtPersonalMessage').value;\r\n" +
  23.                                 "var url = 'DoPreview.aspx?' + em + fn + ln + pn + a1 + a2 + ct + st + zp + cy + pm;\r\n" +
  24.                                 "win = window.open(url, null, 'height=700, width=800,status= no, resizable= yes, scrollbars=yes,toolbar=no,location=no,menubar=no');\r\n" +
  25.                                 "win.focus();\r\n" +
  26.                             "}\r\n" +
  27.                             " -->\r\n" +
  28.                     "</script>\r\n", false);
  29.  
  30.             btnPreview.Attributes.Add("OnClick", "DoPreview()");
  31.  
  32.         }
  33.     }

the problem arises when I first open the window by pressing the btnPreview. The script gets called, I generate a url dynamically, adding a query string to it. The windown opens successfully the first time, however, if I close the popped up window and press that button again, it gives me the error described in the subject.

Anybody have any ideas why I might be running into this problem?

Thanks.
Jan 25 '08 #1
7 24200
acoder
16,027 Expert Mod 8TB
What line do you get the error on?
Jan 25 '08 #2
I get it on the following line:

btnPreview.Attributes.Add("OnClick", "DoPreview()");
Jan 25 '08 #3
acoder
16,027 Expert Mod 8TB
OK, what does the code look like client-side (viewing in the browser)? You should be able to get the generated source code by selecting View Source or View Page Source.
Jan 25 '08 #4
Aha! OK, will do....
Jan 25 '08 #5
Guys, I faced the same error, In my case no StumbleUpon tool was installed. I solved it by dissabling Javascript debugging. Go to IE browser -> Tools->Internet Options -> Advanced -> check 'Dissable script debugging(internet exploere) option. this refers to IE 7.
Apr 16 '09 #6
acoder
16,027 Expert Mod 8TB
But it's a JavaScript problem, so disabling debugging won't help solve it.
Apr 16 '09 #7
This line should be like this:
btnPreview.Attributes.Add("OnClick", "DoPreview();");


I guess you have forgotten to add semicolon after function name.
Nov 19 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Danny | last post by:
Hi I don't understand why I keep getting "Error: Object expected" I tried different things and haven't been able to solve it. I'm a newbie so I'm not sure what I'm doing wrong. The debugger breaks...
0
by: GHS | last post by:
I'm writing code to parse a specific website and decided to use MSHTML to help (instead of regular expressions). The parsing code is complete - looks very nice if I say so myself. :-) The...
16
by: Steve Chapel | last post by:
When I load the page <https://bugzilla.mozilla.org/attachment.cgi?id=237739with Internet Explorer 7 RC 1, I get the error "Object Expected" at line 174. When I click on the button, I also get the...
1
by: monudjn | last post by:
Hi I am implementing ajax in portal. Using ajax i am able to updating the content of portlets asynchronously. However i am facing a problem The Problem: While submitting the form i am getting...
5
by: Diego Ruiz | last post by:
Hi!! my english is not too good, but i'll try it I have a javascript code: function executeCommands(inputparms) { // Instantiate the Shell object and invoke its execute method. ...
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."...
10
by: jasone | last post by:
hi everyone! any advice given will be MUCH appreciated, i have spent about 10 hours on this bit of script... a rating system. I am having realt trouble overcoming this problem at runtime ...
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="<%=...
1
by: ShyamKrishnegowda | last post by:
We are writing test scripts to our product. In one of the script we are facing an issue. This test script will create a COM component and executes the following function. O1 and O2 are out...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.