How to set window size in asp.Net? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

How to set window size in asp.Net?

JamesJames Posts: 217Member
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


Comments

  • raymcdraymcd Posts: 284Member
    : 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
  • iwilld0itiwilld0it Posts: 1,134Member
    : : 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:

    [code]

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

    return false;
    }

    [/code]

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

    [code]

    [/code]

  • JamesJames Posts: 217Member
    : : : 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:
    :
    : [code]
    :
    : function openWindow()
    : {
    : var wnd = window.open(
    : 'somePage.aspx?id=<% =id %>',
    : 'Page Title',
    : 'width=<% =width %>,height=<% =height %>');
    :
    : return false;
    : }
    :
    : [/code]
    :
    : Then you can call the javascript function in an onclick handler for a button for instance ...
    :
    : [code]
    :
    : [/code]
    :
    :

    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

Sign In or Register to comment.