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

RegisterClientScriptBlock: What am I doing wrong

aaa
I am trying to activate the following code on the click event of a popup
window.
If I comment out the lines where I assign the values to the hidden fields
the Parent page submits otherwise it does nothing. I don't get it.
I have used this code before. Any help is appreciated.

string s="<script>";
s += "window.opener.Form1.hiddenID.value = " + 6 + ";";
s += "window.opener.Form1.hiddenFlag.value = \"" + 1 + "\";";
s += "window.opener.Form1.submit();";
s += "window.close();";
s += "</script>";
this.RegisterClientScriptBlock("addPopup",s);
Nov 19 '05 #1
7 1434
Obviously you have a problem with those two lines. The code is
stopping before you get to the submit and close.

Are those two quotation marks in row in the second line? I can't
tell.

I always use

self.opener.document.getElementById('mycontrolname ').value

Instead of referencing Form1.controlname in the calling window. This
helps ensure that the script will work with multiple browsers.

Bill E.
Hollywood, FL

Nov 19 '05 #2
What's the output / behaviour that you're getting?

btw, I support Bill's advice.

Cheers,
Gaurav Vaish
http://mastergaurav.org
http://mastergaurav.blogspot.com
------------------------

Nov 19 '05 #3
aaa
That worked Bill, thanx a bunch!

<bi********@netscape.net> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Obviously you have a problem with those two lines. The code is
stopping before you get to the submit and close.

Are those two quotation marks in row in the second line? I can't
tell.

I always use

self.opener.document.getElementById('mycontrolname ').value

Instead of referencing Form1.controlname in the calling window. This
helps ensure that the script will work with multiple browsers.

Bill E.
Hollywood, FL

Nov 19 '05 #4
aaa
Maybe I spoke too soon. It now does the submit but doesn't pass back
anything. It has something to do with 'document' in the DOM.

How is that different than say Form1 or forms[0], which by the way will not
submit the form.
<bi********@netscape.net> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Obviously you have a problem with those two lines. The code is
stopping before you get to the submit and close.

Are those two quotation marks in row in the second line? I can't
tell.

I always use

self.opener.document.getElementById('mycontrolname ').value

Instead of referencing Form1.controlname in the calling window. This
helps ensure that the script will work with multiple browsers.

Bill E.
Hollywood, FL

Nov 19 '05 #5
Immediately after setting the controls and before submitting, check to
see that the values are actually being written to the controls in the
calling window as in

alert(self.opener.document.getElementById('mycontr olname').value);

Also, how and where are you picking up these values in the calling page
in your code?

Bill

Nov 19 '05 #6
aaa
The values that I assigned it but they are not getting passed to the parent.

<bi********@netscape.net> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Immediately after setting the controls and before submitting, check to
see that the values are actually being written to the controls in the
calling window as in

alert(self.opener.document.getElementById('mycontr olname').value);

Also, how and where are you picking up these values in the calling page
in your code?

Bill

Nov 19 '05 #7
Can you tell us why you're using escape characters in the second line

s += "window.opener.Form1.hiddenFlag.value = \"" + 1 + "\";";

Is hiddenFlag a checkbox? If so, why can't you simply use

s += "window.opener.Form1.hiddenFlag.checked = 1;";

or

s += "self.opener.document.getElementById('hiddenFlag') .checked = 1;";

Bill E.

Nov 19 '05 #8

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

Similar topics

3
by: Reena | last post by:
Hi, private void Page_Load(object sender, System.EventArgs e) { System.Text.StringBuilder strBuilder = new System.Text.StringBuilder(); strBuilder.Append ("<script language=JavaScript> ");...
3
by: Mike P | last post by:
Is there a difference between Page.RegisterClientScriptBlock and Page.RegisterStartupScript? I've seen them both in code examples and they both seem to be doing the same thing. Any help would...
1
by: Mark | last post by:
I'm really pulling my hair out on this. (newbie at ASP.NET) I have a control (called 'header.ascx' ) that I want to place a DHTML(javascript) menu in. I keep getting errors. The menu code is...
2
by: sam | last post by:
I am trying to emit script to the response stream within the Application_Error handler in global.asax. I want to emit using Page.RegisterClientScriptBlock. This doesn't work, and I have been...
1
by: Simon Harris | last post by:
Hi All, I'm trying to write a composite web control which will render a rich text editor. I am having problems with RegisterClientScriptBlock - The script simply doesnt get written. There are...
2
by: kewl | last post by:
Hi All, We have an ASP.NET 2.0 (C#) intranet application that needs to spawn multiple browsers using RegisterClientScriptBlock. Here's what we got so far: // Go thru each datarow in the...
9
by: Nathan Sokalski | last post by:
I have used the RegisterClientScriptBlock method in external functions of mine (ones that are saved in a separate *.vb file), where I use them as follows: Public Shared Sub MyFunction(ByVal...
3
by: | last post by:
Hello, I try to open a new Window in code behind with : ClientScript.RegisterClientScriptBlock(this.GetType(), "MyOpenScript", "window.open('toto.doc');", true); My problem is that the new...
8
by: =?Utf-8?B?UGF1bCBSZWVk?= | last post by:
Hello, I have an app that was xcopy deployed from an ASP.NET 1.1 W2KServer to a box running ASP.NET 2.0 W2003Server. The app runs fine with the exception of where I use the above method. It...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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
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
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...
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.