ASP.NET

Moderators: None (Apply to moderate this forum)
Number of threads: 1727
Number of posts: 3292

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
How to set window size in asp.Net? Posted by James on 2 Jul 2003 at 9:58 AM
I hope this is an easy question. I'm writing a web application and when a user clicks a button, a small pop-up window needs to open with various input controls.

How do I set the size and position of this aspx form when it opens so that it is small and in the middle of the screen?

Thanks


Report
Re: How to set window size in asp.Net? Posted by raymcd on 2 Jul 2003 at 2:35 PM
: I hope this is an easy question. I'm writing a web application and when a user clicks a button, a small pop-up window needs to open with various input controls.
:
: How do I set the size and position of this aspx form when it opens so that it is small and in the middle of the screen?
:
: Thanks
:
You can only control the window size when the url is opened from the client through a clientside script block. You could do something tricky like doing a redirect with window.open and then closing the first window with window.close. Then only one window will be open and you will have opened a new window so you can set the size. I don't remember the syntax but that's generally how you do it.

-Ray
Report
Re: How to set window size in asp.Net? Posted by iwilld0it on 3 Jul 2003 at 5:42 AM
: : I hope this is an easy question. I'm writing a web application and when a user clicks a button, a small pop-up window needs to open with various input controls.
: :
: : How do I set the size and position of this aspx form when it opens so that it is small and in the middle of the screen?
: :
: : Thanks
: :
: You can only control the window size when the url is opened from the client through a clientside script block. You could do something tricky like doing a redirect with window.open and then closing the first window with window.close. Then only one window will be open and you will have opened a new window so you can set the size. I don't remember the syntax but that's generally how you do it.
:
: -Ray
:

You need client-side code to pop open another browser window. However, you can use server-side code to dynamically add the size constraints to the client-side code:

<script language="javascript">
    function openWindow()
    {
       var wnd = window.open(
           'somePage.aspx?id=<% =id %>', 
           'Page Title', 
           'width=<% =width %>,height=<% =height %>');

       return false;
    }
</script>


Then you can call the javascript function in an onclick handler for a button for instance ...

<input type="button" onclick="return openWindow();">


Report
Re: How to set window size in asp.Net? Posted by James on 3 Jul 2003 at 8:47 AM
: : : I hope this is an easy question. I'm writing a web application and when a user clicks a button, a small pop-up window needs to open with various input controls.
: : :
: : : How do I set the size and position of this aspx form when it opens so that it is small and in the middle of the screen?
: : :
: : : Thanks
: : :
: : You can only control the window size when the url is opened from the client through a clientside script block. You could do something tricky like doing a redirect with window.open and then closing the first window with window.close. Then only one window will be open and you will have opened a new window so you can set the size. I don't remember the syntax but that's generally how you do it.
: :
: : -Ray
: :
:
: You need client-side code to pop open another browser window. However, you can use server-side code to dynamically add the size constraints to the client-side code:
:
:
: <script language="javascript">
:     function openWindow()
:     {
:        var wnd = window.open(
:            'somePage.aspx?id=<% =id %>', 
:            'Page Title', 
:            'width=<% =width %>,height=<% =height %>');
: 
:        return false;
:     }
: </script>
: 

:
: Then you can call the javascript function in an onclick handler for a button for instance ...
:
:
: <input type="button" onclick="return openWindow();">
: 

:
:

I bow to thee Oh Great Gurus IWillDoIt and Raymcd. You've given me the exact concepts and code snippet I need.

Thank you so much.

James




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.