473,387 Members | 1,641 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.

window.open is not working from code behind file

390 Expert 256MB
Hi,

I have one page developed in C# ASP.NET 2.0.
I am trying to open a new window from my code behind file.

My code is like below
string pageName = "EntityDescription.aspx?Ecode=" + "'" + entityCode + "'" + "& EDesc=" + "'" + entityDesc + "'";
String scriptString = "<script type='text/javascript'>" ;
scriptString += "window.onload = function(){ window.open('" + pageName + "' ,'test');}</script>";
ClientScript.RegisterClientScriptBlock(this.GetTyp e(), "clientScript", scriptString);


It is not giving any error.But it is not opening the new window for me.
Can someone help me on this.
Jun 25 '08 #1
10 4727
Plater
7,872 Expert 4TB
Well that is javascript, that should be executed client side. Where is this code being run?
Jun 25 '08 #2
mzmishra
390 Expert 256MB
Yes that is javascript.I am actually trying to open a new window when some text is selected in dropdown.
so i have put this code in dropdown selected index change method in code behind file.

I did something like this in my prev project in .net1.1.it was working fine.
but here it is not :(
Jun 25 '08 #3
Plater
7,872 Expert 4TB
Does .net1.1 have the .AddAttribute() function on it's controls?
Jun 25 '08 #4
mzmishra
390 Expert 256MB
no it did not.is it reqd?
Jun 25 '08 #5
Plater
7,872 Expert 4TB
no, it just would have made that really easy to do.
Have you tried changing your function to using Alert()s just for debug to see if it even makes it into your script?
Jun 25 '08 #6
mzmishra
390 Expert 256MB
yes alert works fine.but window.open not
Jun 25 '08 #7
Plater
7,872 Expert 4TB
Blocked by a popup blocker, or otherwise not allowed?
Jun 25 '08 #8
mzmishra
390 Expert 256MB
nope .no setting turnoff pop up.
window .open code in clientside for other pages working fine
Jun 25 '08 #9
Plater
7,872 Expert 4TB
Oh wow I totally got throw off. You ARE in .net2.0.

Well anyway, I saw this, which is slightly different then what you had?
Expand|Select|Wrap|Line Numbers
  1. ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "alert('Hi');", true);
  2.  
I think you would replace the alert('hi') to be the window.open() call.

And not have those extra script tags, which might be what is causing the trouble?
Jun 25 '08 #10
mzmishra
390 Expert 256MB
This code did not work.
Jun 25 '08 #11

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

Similar topics

12
by: HarveyB | last post by:
I would like to generate non-modal popup windows from ASP.Net code-behind. I have tried using Client Side scripting like "function Test(){ window.open('test.htm',_blank,...
14
by: D. Alvarado | last post by:
Hello, I am trying to open a window containing an image and I would like the image to be flush against the window -- i.e. have no padding or border. Can I make this happen with a single call to a...
5
by: Mark | last post by:
Hi all, how do I open a javascript window from a code behind page? I was using Response.Write("<script language='javascript'>window.open('url','name','options');</script>") but now for some...
2
by: carlor | last post by:
Hi there, I have a form that contains a link button. When the user clicks the link button I need to enable a couple of other buttons on the page and open a new browser window giving it focus...
4
by: alexandre.brisebois | last post by:
Hi, I am using access 2003, I would like to know if there is an option to reorganize the tables in a maner that is readable, as we can do in sql sever 2000 or 2005. I have been given a database...
0
by: IndyChris | last post by:
I've got a button my webpage that when clicked will open another window. Different criteria on the page will deteremine which window gets opened when the button is clicked. I have a switch...
13
by: Bob Jones | last post by:
Here is my situation: I have an aspx file stored in a resource file. All of the C# code is written inline via <script runat="server"tags. Let's call this page B. I also have page A that contains...
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...
16
by: CreativeMind | last post by:
hi, i have a page calendar.aspx which returns selected date i.e window.returnValue=selectedDate; window.close(); it works fine with IE but not for Firefox. i tried...
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:
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: 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...
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...
0
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,...
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...

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.