Solved

c#, javascript open a new window

Posted on 2010-08-12
6
429 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
  • 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Converting C# Objects into JSON file 7 39
Code enhancement 5 12
ASP.Net Session State alternatives 3 28
Jquery autocomplete 10 27
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now