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

Problem with Window.open Javascript.

Hi,

Thanks in advance for answering to my Question. I'm stuck with this
problem and would really appreciate any help.

I have 2 aspx files (Main.aspx and ReportViewer.aspx). Main.aspx has a
datagrid which is populated with list of report names. When the user
click on the name of a report, I display a panel that has a button
which on clicking will run the report. The report will open in
ReportViewer.aspx, This page has a Report Document and
CrystalReportViewer.

I have the Window.open Javascript on Main.aspx which is pasted below.
----------------------
</script>
<script language="JavaScript">

<!--//

function new_window(url) {

link = window.open(url,"Link","toolbar=0,location=0,direc tories=0,status=0,menubar=0,scrollbars=1,resizable =1,width=1010,height=600,left=0,top=0");

}
//-->
</script>
-----------------------

I have the Following code on the Click event of the button in
Main.aspx
------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Session("ReportPath") = mygrid.SelectedItem.Cells(2).Text
Button1.Attributes.Add("onClick",
"new_window('ReportViewer.aspx')")
End Sub
------------------------

I have the Following code in ReportViewer.aspx.
------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Report.Load(Session("ReportPath"))
CrystalReportViewer1.ReportSource = Report
End Sub

------------------------
Here is my Problem. In Main.aspx, when i select a report name and
click the button the first time, I just see the process bar quickly
running from start to end. The report doesn't open. When i click the
button the second time, the report opens fine in a new window. But
then, if i select another report after that and click the button, the
same report opens again instead of opening the new report that i
selected.
How do i resolve this.

Hope i've explained my problem clearly.

Thanks
Shamin
Nov 18 '05 #1
6 2680
Session("ReportPath") = mygrid.SelectedItem.Cells(2).Text
Button1.Attributes.Add("onClick",
"new_window('ReportViewer.aspx')")
That will not work.
You cannot both have a Server On Click and a Client-Side JavaScript for a
button.
In this case because the Client Side OnCLick is being added when the Same
Button is pressed it never gets done.

I think that you want to look at RegisterClientScriptBlock to accomplish the
creation of the NewWindow upon a certain button click if you need the Server
Side button click and a window to open at the same time. Please be advised
however that this is a faulty design as this will most likely get blocked by
popup blockers which will now ship by default on.


"Shamin" <sh******@hotmail.com> wrote in message
news:44**************************@posting.google.c om...
Hi,

Thanks in advance for answering to my Question. I'm stuck with this
problem and would really appreciate any help.

I have 2 aspx files (Main.aspx and ReportViewer.aspx). Main.aspx has a
datagrid which is populated with list of report names. When the user
click on the name of a report, I display a panel that has a button
which on clicking will run the report. The report will open in
ReportViewer.aspx, This page has a Report Document and
CrystalReportViewer.

I have the Window.open Javascript on Main.aspx which is pasted below.
----------------------
</script>
<script language="JavaScript">

<!--//

function new_window(url) {

link =
window.open(url,"Link","toolbar=0,location=0,direc tories=0,status=0,menubar=0,scrollbars=1,resizable =1,width=1010,height=600,left=0,top=0");

}
//-->
</script>
-----------------------

I have the Following code on the Click event of the button in
Main.aspx
------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Session("ReportPath") = mygrid.SelectedItem.Cells(2).Text
Button1.Attributes.Add("onClick",
"new_window('ReportViewer.aspx')")
End Sub
------------------------

I have the Following code in ReportViewer.aspx.
------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Report.Load(Session("ReportPath"))
CrystalReportViewer1.ReportSource = Report
End Sub

------------------------
Here is my Problem. In Main.aspx, when i select a report name and
click the button the first time, I just see the process bar quickly
running from start to end. The report doesn't open. When i click the
button the second time, the report opens fine in a new window. But
then, if i select another report after that and click the button, the
same report opens again instead of opening the new report that i
selected.
How do i resolve this.

Hope i've explained my problem clearly.

Thanks
Shamin



Nov 18 '05 #2
Session("ReportPath") = mygrid.SelectedItem.Cells(2).Text
Button1.Attributes.Add("onClick",
"new_window('ReportViewer.aspx')")
That will not work.
You cannot both have a Server On Click and a Client-Side JavaScript for a
button.
In this case because the Client Side OnCLick is being added when the Same
Button is pressed it never gets done.

I think that you want to look at RegisterClientScriptBlock to accomplish the
creation of the NewWindow upon a certain button click if you need the Server
Side button click and a window to open at the same time. Please be advised
however that this is a faulty design as this will most likely get blocked by
popup blockers which will now ship by default on.


"Shamin" <sh******@hotmail.com> wrote in message
news:44**************************@posting.google.c om...
Hi,

Thanks in advance for answering to my Question. I'm stuck with this
problem and would really appreciate any help.

I have 2 aspx files (Main.aspx and ReportViewer.aspx). Main.aspx has a
datagrid which is populated with list of report names. When the user
click on the name of a report, I display a panel that has a button
which on clicking will run the report. The report will open in
ReportViewer.aspx, This page has a Report Document and
CrystalReportViewer.

I have the Window.open Javascript on Main.aspx which is pasted below.
----------------------
</script>
<script language="JavaScript">

<!--//

function new_window(url) {

link =
window.open(url,"Link","toolbar=0,location=0,direc tories=0,status=0,menubar=0,scrollbars=1,resizable =1,width=1010,height=600,left=0,top=0");

}
//-->
</script>
-----------------------

I have the Following code on the Click event of the button in
Main.aspx
------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Session("ReportPath") = mygrid.SelectedItem.Cells(2).Text
Button1.Attributes.Add("onClick",
"new_window('ReportViewer.aspx')")
End Sub
------------------------

I have the Following code in ReportViewer.aspx.
------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Report.Load(Session("ReportPath"))
CrystalReportViewer1.ReportSource = Report
End Sub

------------------------
Here is my Problem. In Main.aspx, when i select a report name and
click the button the first time, I just see the process bar quickly
running from start to end. The report doesn't open. When i click the
button the second time, the report opens fine in a new window. But
then, if i select another report after that and click the button, the
same report opens again instead of opening the new report that i
selected.
How do i resolve this.

Hope i've explained my problem clearly.

Thanks
Shamin



Nov 18 '05 #3

Hi,

Thanks for the reply and advice. Is there a different way i can
accoomplish this.

Thanks


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4

Hi,

Thanks for the reply and advice. Is there a different way i can
accoomplish this.

Thanks


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #5
You could place a literal inside of a script tag, and then populate the
literal from your button click method.

For example, in your html you could do something like....
<script language="javascript">
<asp:Literal id="MyLiteral" runat="server"
EnableViewState="False"></asp:Literal>
</script>

Then, in your button click method...
MyLiteral.Text = "window.open('" & urlvalue & "');"
MyLiteral.EnableViewState = True

You'd have to tweak it a bit to get your window settings and such. I've
found it quite useful - expecially for alert boxes.
- Chad

"ASP Guy" <my****@mymail.com> wrote in message
news:uw**************@TK2MSFTNGP09.phx.gbl...

Hi,

Thanks for the reply and advice. Is there a different way i can
accoomplish this.

Thanks


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #6
Here it is...

Dim PopupScript As String
PopupScript = "<script>popReportWindow('<<someparamvalue>>') </script>"
MyBase.Page.RegisterStartupScript("<<somescriptkey >>", PopupScript)

Rather than writing all the script in the code-behind, create the bulk
of the javascript in the aspx and add a RegisterStartupSCript
reference in code. The script will appear just before the closing
form tag.
sh******@hotmail.com (Shamin) wrote in message news:<44**************************@posting.google. com>...
Hi,

Thanks in advance for answering to my Question. I'm stuck with this
problem and would really appreciate any help.

I have 2 aspx files (Main.aspx and ReportViewer.aspx). Main.aspx has a
datagrid which is populated with list of report names. When the user
click on the name of a report, I display a panel that has a button
which on clicking will run the report. The report will open in
ReportViewer.aspx, This page has a Report Document and
CrystalReportViewer.

I have the Window.open Javascript on Main.aspx which is pasted below.
----------------------
</script>
<script language="JavaScript">

<!--//

function new_window(url) {

link = window.open(url,"Link","toolbar=0,location=0,direc tories=0,status=0,menubar=0,scrollbars=1,resizable =1,width=1010,height=600,left=0,top=0");

}
//-->
</script>
-----------------------

I have the Following code on the Click event of the button in
Main.aspx
------------------------
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Session("ReportPath") = mygrid.SelectedItem.Cells(2).Text
Button1.Attributes.Add("onClick",
"new_window('ReportViewer.aspx')")
End Sub
------------------------

I have the Following code in ReportViewer.aspx.
------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Report.Load(Session("ReportPath"))
CrystalReportViewer1.ReportSource = Report
End Sub

------------------------
Here is my Problem. In Main.aspx, when i select a report name and
click the button the first time, I just see the process bar quickly
running from start to end. The report doesn't open. When i click the
button the second time, the report opens fine in a new window. But
then, if i select another report after that and click the button, the
same report opens again instead of opening the new report that i
selected.
How do i resolve this.

Hope i've explained my problem clearly.

Thanks
Shamin

Nov 18 '05 #7

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

Similar topics

4
by: Marco | last post by:
I made an html-page with this line in it: <A HREF="http://www.bla.com" onClick="javascript:window.close()" target="moeder">link</A> It works very well in Internet Explorer, but in Netscape 7...
2
by: Christian Kusenbach | last post by:
Hello group! I've a problem with JavaScript and IMG-Objects. On my webpage I use a big image and several small images. If you click on a small image, it executes a JavaScript to change the...
4
by: Anna Quick | last post by:
I am quite new to javascript, and don't seem to find the problem with stupid internet explorer. The script works fine in safari and mozilla. I searched the groups, but evidently put in the wrong...
1
by: Julius Mong | last post by:
Dear all, according to the ASV3 manual known problem section, to make an <a> execute some Javascript onclick: ...
2
by: Samir Pandey | last post by:
Hello, I am using the following javascript code to open a new window. Somehow, IE always opens a new window. It doesn't open target url in the window name given. All i want is, if there is a...
4
by: VR | last post by:
First, greetings to everyone :) I'm doing a university seminar & I've encountered a problem. I have a gallery with thumbnails linked on pictures. What I want is popup to be opened with...
18
by: len.hartley | last post by:
Hi, I am trying to pop-up a window when the user clicks on an image. The problem is that when the user clicks on the image and the window pops up OK, but the window underneath also proceeds to...
5
by: althafexcel | last post by:
hi everyone Im trying to include an external js in my aspx page under the head tag, it doesn't load or it displays an object expected error whenver the function from the .js is called. Actually...
2
by: swethak | last post by:
Hi, I am getting the problem the problem with google map in Internet Explorer. This map worked fine in mozilla . When i opened the same map in Internet Explorer i am getting the error...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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,...
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
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,...

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.