View Light

HOWTO: Set the size of a child window opened from datagrid

In my last post I discussed how to link to a URL and pass the record identifier from a DataGrid Hyperlink column.

Moving along a bit further with this, you can have the URL opened in a child window by setting the Target field in the DataGrid Property Builder.

However, on doing this, there is a drawback in some cases: The child browser window opens to the same size as the parent browser window, fully occluding the parent window. In my case, I'd rather have the child window open smaller than the parent window to make switching between the two easier. However, I could not find a way to configure a target window size with the DataGrid Property Builder, so I had to research another approach to handling this issue:

The answer is pretty easy:

Open the child window in Visual Studio in Design mode and switch to HTML view and add onload="resizeTo(,)" to the BODY tag of the document.

For example:

If you want it under programmatic control, you can 'punch in' a session variable in place of the Width and Height values and just populate the session variables with the desired size before populating the datagrid:

onload="resizeTo(

,

)"

Reply
This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available in our efforts to advance understanding of environmental, political, human rights, economic, democracy, scientific, and social justice issues, etc. We believe this constitutes a 'fair use' of any such copyrighted material as provided for in section 107 of the US Copyright Law. In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit to those who have expressed a prior interest in receiving the included information for research and educational purposes. For more information go to: http://www.law.cornell.edu/uscode/17/107.shtml . If you wish to use copyrighted material from this site for purposes of your own that go beyond 'fair use', you must obtain permission from the copyright owner.