473,799 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.as px). 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.as px, This page has a Report Document and
CrystalReportVi ewer.

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

<!--//

function new_window(url) {

link = window.open(url ,"Link","toolba r=0,location=0, directories=0,s tatus=0,menubar =0,scrollbars=1 ,resizable=1,wi dth=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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Session("Report Path") = mygrid.Selected Item.Cells(2).T ext
Button1.Attribu tes.Add("onClic k",
"new_window('Re portViewer.aspx ')")
End Sub
------------------------

I have the Following code in ReportViewer.as px.
------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Report.Load(Ses sion("ReportPat h"))
CrystalReportVi ewer1.ReportSou rce = 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 2734
Session("Report Path") = mygrid.Selected Item.Cells(2).T ext
Button1.Attribu tes.Add("onClic k",
"new_window('Re portViewer.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 RegisterClientS criptBlock 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******@hotma il.com> wrote in message
news:44******** *************** ***@posting.goo gle.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.as px). 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.as px, This page has a Report Document and
CrystalReportVi ewer.

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

<!--//

function new_window(url) {

link =
window.open(url ,"Link","toolba r=0,location=0, directories=0,s tatus=0,menubar =0,scrollbars=1 ,resizable=1,wi dth=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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Session("Report Path") = mygrid.Selected Item.Cells(2).T ext
Button1.Attribu tes.Add("onClic k",
"new_window('Re portViewer.aspx ')")
End Sub
------------------------

I have the Following code in ReportViewer.as px.
------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Report.Load(Ses sion("ReportPat h"))
CrystalReportVi ewer1.ReportSou rce = 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("Report Path") = mygrid.Selected Item.Cells(2).T ext
Button1.Attribu tes.Add("onClic k",
"new_window('Re portViewer.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 RegisterClientS criptBlock 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******@hotma il.com> wrote in message
news:44******** *************** ***@posting.goo gle.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.as px). 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.as px, This page has a Report Document and
CrystalReportVi ewer.

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

<!--//

function new_window(url) {

link =
window.open(url ,"Link","toolba r=0,location=0, directories=0,s tatus=0,menubar =0,scrollbars=1 ,resizable=1,wi dth=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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Session("Report Path") = mygrid.Selected Item.Cells(2).T ext
Button1.Attribu tes.Add("onClic k",
"new_window('Re portViewer.aspx ')")
End Sub
------------------------

I have the Following code in ReportViewer.as px.
------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Report.Load(Ses sion("ReportPat h"))
CrystalReportVi ewer1.ReportSou rce = 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="javas cript">
<asp:Literal id="MyLiteral" runat="server"
EnableViewState ="False"></asp:Literal>
</script>

Then, in your button click method...
MyLiteral.Text = "window.ope n('" & urlvalue & "');"
MyLiteral.Enabl eViewState = 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******** ******@TK2MSFTN GP09.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>popRep ortWindow('<<so meparamvalue>>' )</script>"
MyBase.Page.Reg isterStartupScr ipt("<<somescri ptkey>>", PopupScript)

Rather than writing all the script in the code-behind, create the bulk
of the javascript in the aspx and add a RegisterStartup SCript
reference in code. The script will appear just before the closing
form tag.
sh******@hotmai l.com (Shamin) wrote in message news:<44******* *************** ****@posting.go ogle.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.as px). 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.as px, This page has a Report Document and
CrystalReportVi ewer.

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

<!--//

function new_window(url) {

link = window.open(url ,"Link","toolba r=0,location=0, directories=0,s tatus=0,menubar =0,scrollbars=1 ,resizable=1,wi dth=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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Session("Report Path") = mygrid.Selected Item.Cells(2).T ext
Button1.Attribu tes.Add("onClic k",
"new_window('Re portViewer.aspx ')")
End Sub
------------------------

I have the Following code in ReportViewer.as px.
------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
Report.Load(Ses sion("ReportPat h"))
CrystalReportVi ewer1.ReportSou rce = 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
2575
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 the url isn't opened in the moeder window. How come and how can I fix it so it works in Netscape too? Thanks in advance for any answers. Mrco
2
7643
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 source of the big image to the source of the small image. It's working fine, but on some browsers (I use IE 6.0.2800.1106) the image doesn't change properly. I click on the image and the big image turns white. Now I have to
4
7596
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 keywords, didn't find the solution. It seems to be as easy as it gets: open a new window with a new url. in IE (I am using IE in mac osx), the error message is: Microsoft JScript runtime error: Line: 9
1
2016
by: Julius Mong | last post by:
Dear all, according to the ASV3 manual known problem section, to make an <a> execute some Javascript onclick: http://www.google.co.uk/search?q=cache:OPDjMJfL50sJ:www.adobe.com/svg/indepth/pdfs/ReadMewin.pdf+adobe+svg+javascript+problem&hl=en&ie=UTF-8#5 4. Due to design limitations of Netscape, avoid using HTML with the following form: <a href="#" onclick="myScriptWhichModifiesSVG()">The problem is that JavaScript responds to the onclick...
2
3510
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 window "MyWin" already open, then the main window should load the target url in "MyWin" and not open a new window again.
4
2435
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 dimensions of linked picture after clicking on a thumbnail. I found javascript which is compatible with IE, Firefox & Opera but I can't get it to work. All I get is this http://www.justfonts.com/tini/problem.html (thumbnail dissapeared).
18
3350
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 the image. The desired behavior is that when the pop-up is invoked, I want the underlying window to stay put. I don't have this problem when I run the code on my local computer but I do have it when I run the code on geocities.
5
3701
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 for repeated html im using the external js, i mean the TOP, BOTTOM they are repeated in every page, so i include them as functions in the external js and call them. Why it doesn't work?
2
3157
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 message as in alert box as " Internet Explorer cannot open the Internet site http://google.citycarrentals.com.au/viewalllocations.php . Operation aborted". It is working in Mozilla . Here i mentioned my code . I am facing this problem several...
0
9689
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
10495
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
10269
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9085
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...
0
6811
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
5597
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4148
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2942
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.