Howdy, Stranger!

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

Categories

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.