ASP.NET Disable page formatting when not full screen - c#

I have a web application on VS2005 using C#.
Whenever my webpage does not open up in full screen, the icons and labels will automatically adjust to fit the width of the windows, making the buttons and icons disoriented.
Is there any way to disable this or enable the format to be fixed regardless if the windows is full screen or not?

This would be hard to do. You could use a function in javascript to chceck if browser is in full screen. Then you woud have to do this in intervals to make sure that this is or is not true.
if (screen.width == window.innerWidth && screen.height == window.innerHeight) {
// web browser full screen
}
Based on that you could make another screen CSS template that you could apply based on that condition. Then you could make your site apply another layout.
Another approach I would reccoment is to make your CSS layout in a way that you would be satisfied with it with any browser size.

You can use CSS to set width (which will be fixed) or min-width (layout will not shrink to less). min-width is not supported on older versions of IE.
In both cases if the browser window is smaller (or the available space – if something like history is opened down the side) than this then horizontal scrolling will be alloed.
However consider that many users have very wide screens these days, far too wide for comfortable reading if a browser is maximised.

Related

Show C# WinForm on different screens

On my workstation I have developed a WinForm application. With panels, buttons and dropdowns.
After that I applied the application to my laptop.
On my laptop the presentation of the application was not correct. The elements overlap and the buttons are warped.
Can you tell me how to handle this?
I apologize for my english. This text was written with Google translator.
It is a bit difficult to tell from the distance, but I guess the window uses a different size on the laptop and the controls' docking and anchoring are not configured to do what you want. I suggest this and this tutorial on how to configure the properties; this is preferrably done in the designer instead of code for a fixed layout.
I've seen this behavior running Windows with a "display size" setting greater than 100%. Try resetting this value in your display settings:
Make sure to develop your forms on a computer with the system DPI setting set to 100%. Visual Studio will automatically convert your form coordinates depending on this system setting (it's a bug according to me). A quick way to fix a form is to do the following:
Make sure the system DPI setting is set to 100%.
Move a button in the form one pixel to the left. Then move it back again.
Save. Compile. Run.
1.] Either use Anchor or Dock
2.] Or try to fix the minimum and maximum size of your form and disable maximize button

Dot Net Nuke : Selecting different skin files based on the browser width change

Is there any way of selecting different skin files(.ascx files) in DNN when there is a change in the browser or window width?
In addition to it, is there any event in asp.net that is triggered whenever there is any change in the width/size of the browser?
You can create separate sites for different devices using DNN's "Device Preview Management"and "Site Redirection"
http://www.dnnsoftware.com/community/learn/video-library/view-video/video/532/view/details/redirecting-website-visitors-to-your-mobile-website-using-dotnetnuke
To answer the question, you'll need to use JavaScript to update the stylesheet url based on browser width. In javascript, you can get the viewport's width with
window.innerWidth
However, a much better approach would be to employ responsive design in the design of your theme. Modern CSS is capable of handling much of the calculation for modifying layout based on viewport size with an elegant and simple syntax.
To assist you in this, you may want to use a responsive design framework such as bootstrap or foundation

How can I get browser screen resolution on asp.net mvc controller?

I am developing responsive web application in the asp.net mvc.
I want to set some product boxes based on the Current browser/screen resolution, but i am getting issue in getting the correct width of browser resolution.
If I write Request.Browser.ScreenPixelsWidth it gives me all time 640*480.
But its wrong. And if I write the var screen = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
var width = screen.Width;
Its giving me correct windows resolution which i have set from my window property. Its giving me 1600*900 which is correct value. But issue here is if i manually make my browser screen small and run again that code at that it also gives me 1600*900, but it should give me the size of what i have done manually small.
Any idea?
Handling browser size on the server, you won't know if the user resizes the browser between requests. The correct way to handle browser size is on the client with CSS media queries. Media queries allow you to dynamically set different styles for different browser sizes, i.e. a more responsive layout. Here's a decent intro:
http://kyleschaeffer.com/development/responsive-layouts-using-css-media-queries/

C# Web Form button size change when running from different OS

I can not figure out why my web form buttons change size when I run the web form from Windows 7 vs. Windows Server 2003. I have set the positioning and size on page load for all objects. Here is an example of a couple of the objects I am using.
Label1.Style.Add("Position", "fixed");
Label1.Style.Add("TOP", "20px");
Label1.Style.Add("Left", "50px");
btnQuery.Style.Add("Position", "fixed");
btnQuery.Style.Add("TOP", "370px");
btnQuery.Style.Add("Left", "198px");
The buttons have the same 3 entries. When I run this from my local Windows 7 PC, everything looks great. However, when I publish this to my Server 2003 site, the buttons are about 5 times longer and cover each other up. My label, textbox, and listbox are all fine as well. It is just the buttons. Is it because I am developing on Windows 7? Also, I am doing this in Visual Studio 2010, Framework 4.
They are changing because you are giving the size in pixels. If users have different screen resolutions, then it will change how large the buttons are in relation to the screen. Use relative sizing to fix this. This is not OS dependent, may just seem like it.
You're only setting the top/left position of the button, but not the size... If not specified, then web browsers are free to make buttons look however they want.
Assuming that this Style.Add method actually translates to CSS, try adding:
btnQuery.Style.Add("height", "120px");
btnQuery.Style.Add("width", "300px");
Then tweak those so its the size you want.
Generally, I'd advise against using fixed positioning at all, but that is a different story.

Program Size Problem made in C#

I have made a program within C# which i have now published from it but a problem occuyrs when i try to install it on different machines to mine. On my computer the program window size is fine but on other computers its sometimes too small and sometimes too big so the user can not properly look at the main screen of the program. I don't know what to do to change this problem, either within the computer settings or possibly in C# in the code of my project. Please Help,
Thanks,
Chris.
Use Dock and Anchor
It sounds like different users have different screen resolutions. Thats just part of developing software for a variety of users, with differing screen options. You should test your app is usable with different settings and possibly adjust font sizes, layout and dimensions accordingly.
If I'm guessing correctly the problem here isn't the screen resolution but that the actual program window changes size, either hiding parts of the program or showing too much? In that case you should take a look in your WPF editor (if you're using WPF, that is) and check the different Layout/Size options.
You need to use the Anchor properties and Dock properties of your controls (inside the form) to allow your program to be resized. If you can successfully resize it on your computer it should work on others too.
Part from that you may want to set the form to fixed size so that users can't resize it.
You can use the Screen class to get the bounds of the available screens, and from there you should be able to tell if your initial window size is too small and adjust it accordingly. You should probably take care to do this once on the initial launch of the application, just in case the user explicitly and intentionally moves/resizes the window so it doesn't completely cover the screen -- you wouldn't want to accidentally obliterate their changes the next time you run (assuming you even save window positions).

Categories