Solved

c#, javascript open a new window

Posted on 2010-08-12
6
433 Views
Last Modified: 2013-12-17
Hi,

I want to open a window with c# code that has something like this

"javascript:window.open('MoreImages.aspx?','','left=250px, top=245px, width=700px, height=450px, scrollbars=no, status=no, resizable=no');return false;"

how can i use this in c# code

Please ehlp

Thanks,

R8VI
0
Comment
Question by:R8VI
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 23

Accepted Solution

by:
Rajkumar Gs earned 500 total points
ID: 33421303
Here is the javascript & c# code

Raj
// Javascript code
function f_open_window_max( aURL, aWinName )
{
   var wOpen;
   var sOptions;

   sOptions = 'status=yes,menubar=no,scrollbars=yes,resizable=no,toolbar=yes';
   sOptions = sOptions + ',width=' + (screen.availWidth - 10).toString();
   sOptions = sOptions + ',height=' + (screen.availHeight - 200).toString();
   sOptions = sOptions + ',screenX=0,screenY=0,left=0,top=100';

   wOpen = window.open( '', aWinName, sOptions );
   wOpen.location = aURL;
   wOpen.focus();
   wOpen.moveTo( 0, 0 );
   wOpen.resizeTo( screen.availWidth, screen.availHeight );
   return wOpen;
}

// C# Code

                Dim strjscript As String = "<script language='javascript'>"
                strjscript += "f_open_window_max('WorkOrder_PrintPreview.aspx?Job_ID=" & CType(intJobId, String) & "');"
                strjscript += "</script" + ">"
                ClientScript.RegisterStartupScript(Me.GetType, "workorder", strjscript)

Open in new window

0
 

Author Comment

by:R8VI
ID: 33421437
hi thanks for this i changed the dimensions in the function javascript but this still is too big how can i change the code to have the dimesions i sent in the question
0
 

Author Comment

by:R8VI
ID: 33421500
also it has to return false
0
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

 

Author Comment

by:R8VI
ID: 33421645
hi, i got it to work how i want but how to i center the new window
0
 
LVL 23

Assisted Solution

by:Rajkumar Gs
Rajkumar Gs earned 500 total points
ID: 33421724
To load in center screen, try this parameter in that javascript code.
left = NaN,top = NaN

This site may help you, if you want to customize it
http://www.bratta.com/menu_javascripts/pop_up_window/pop_up_window.html

Raj
0
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 33427975
Please Try This one.
 
Dim strjscript As String = "<script language='javascript'>"
 strjscript += "window.open('MoreImages.aspx?','','left=250px, top=245px, width=700px, height=450px, scrollbars=no, status=no, resizable=no');return false';"
 strjscript += "</script" + ">"
ClientScript.RegisterStartupScript(Me.GetType, "workorder", strjscript)
0

Featured Post

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question