Solved

c#, javascript open a new window

Posted on 2010-08-12
6
432 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

749 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