how to open screen on full screen - c#

how i can open my asp.net program on full screen (like i press F11)
Through C# code ?
thanks

Use javascript
Button1.Attributes.Add("onclick","window.open('Default.aspx','','fullscreen=yes')");
not exactly full screen but pretty similar

Have a look at this. Instead of linking, you can redirect your user from your default page with the proper javascript.

Maybe you can send a F11 key pressed command from your application once it's loaded to force your browser to go full screen?
I doubt if there is a clean way of doing this as the F11 fullscreen command is handled by your internet browser.

I think OP is talking about asp.net application so the "program" here is browser.
If it is true, you need client-side javascript to do that. something like this:
<script language="JavaScript1.2">
top.window.moveTo(0,0);
if (document.all)
{ top.window.resizeTo(screen.availWidth,screen.availHeight); }
else if (document.layers || document.getElementById) {
if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth)
{
top.window.outerHeight = top.screen.availHeight;
top.window.outerWidth = top.screen.availWidth;
}
}
</script>
document.all works for Internet Explorer while document.layers works for Other browsers.
top refers to the window that is on top of all other windows in the window object hierarchy.
top.window.moveTo(0,0) will display the top window at these coordinates ie. the upper left corner of the screen.
resizeTo(x,y) will resize the window to the size specified.
availWidth and availHeight are properties of the screen object which can detect the available screen space.
Hope this helps...

Related

Full Screen mode not working while loading the web page in a new window

I used the following code segment to move from A.aspx web page to B.aspx web page and I need to load the B.aspx page in full screen mode in a separate window. I am able to load the content on a separate window but unable to make it to display in full screen. The window just appears to the half of the screen
Response.Redirect("B.aspx", "", "fullscreen=yes");
I have tried it with the ScriptManager as well but again I am facing the same problem. Following is the code segment.
string url = "B.aspx";
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "window.open(' " + url + "', '', 'fullscreen=yes,resizable=no,scrollbars=yes,toolbar=no,menubar=no,status=yes' );", true);
I have also tried setting the width and height of the window and got the same output!
Note: The problem occurs on Google Chrome and Microsoft Edge browsers. When I run the program on Firefox, the page got loaded in full screen. Is this a browser problem or is there any way to achieve this where it is compatible with all the browsers?
There are several mistakes and recommendations here:
1) Response.Redirect() method only accept a maximum of 2 parameters, therefore you cannot use fullscreen=yes as third parameter.
2) fullscreen=yes as window.open() parameter only works for IE (and older Firefox), but not all versions supported (MDN reference). You need to use browser specific APIs on the target page instead.
Hence, as mentioned before, you should add a function to call fullscreen API depending on the client browser:
function fullScreenMode(element) {
if(element.requestFullscreen)
element.requestFullscreen();
else if(element.mozRequestFullScreen)
element.mozRequestFullScreen();
else if(element.webkitRequestFullscreen)
element.webkitRequestFullscreen();
else if(element.msRequestFullscreen)
element.msRequestFullscreen();
}
Then modify RegisterStartupScript like this:
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW",
"window.open('" + url + #"', '', 'resizable=no,scrollbars=yes,toolbar=no,menubar=no,status=yes' );", true);
And call fullScreenMode(document.documentElement) function on the target page when user triggering certain DOM event, because some browsers put limitations to prevent pop-up window abuse in similar way to window.open() function.
Related issue:
How to open a web page automatically in full screen mode
Setting the whole window to be fullscreen in recent browsers

C# WebBrowser turn off jquery popups

I have an application that uses WebBrowser control to navigate from page to page, on some pages I get a leaving popup asking me if that's what I want to do.. this stops the whole further execution until I press "Leave" or "Stay".. How can I disable them?
What I've tried so far were these actions:
a) setting window.onbeforeunload = null;
b) setting alert, confirm, prompt to an empty function
c) settin suppressErrorMessages to true
but even so, I still get the nasty message in the end.
I mostly relied on this answer:
How to update DOM content inside WebBrowser Control in C#?
But so far without a success.
The alerts seem to be jQuery alerts because they have custom texts (instead of OK Cancel, they have Stay Leave)..
Any help hugely appreciated!!
The webbrowser control uses IE internally and IE has a prompt if you've filled out a form asking you if you really want to leave the page (thereby losing the content you've filled out) perhaps that's what you're seeing?
i'm just shooting from the hip here but you could try clearing all inputs before navigating.

Force html link to open in a new window

There's no easy way to explain this but, I have a website, that links to a online game I've made using asp C#. The website has a link to the game so when the user clicks the link on the site, my game pops up! Simples...
But I want it to pop up in a new Window! but not a browser window... Just... A Window :s
for Example, if you go on www.dofutoshiki.com and click on the "Play Futoshiki in our online player" link, it opens a new window with, just the game. No browser functionality.
I was wondering if anybody out there could shed some light on the subject...
Ive Tried:
Click me!
but it just opens a new tab in the browser!
Thanks!
Alex
If I get this right, you actually want a browser window but without the chrome/UI.
For this, you need to use window.open() (javascript) rather than a target attribute.
http://www.pageresource.com/jscript/jwinopen.htm will help you.
You have to open the new window by using javascript and disabling the unwanted functionality by passing arguments.
You will probably need some javascript for this. What you need to look in to is the
'window.open(...)' function.
Here are a few examples.
And here you can play around with it.
Use javascript Window.open method
Click me!
<script>
function openGame(){
window.open(blahblah.aspx,'Play Game','width=900,height=790,scrollbars=yes,dependent=yes,toolbar=no,location=no,status=no,directories=n o,menubar=no,status=no,resizable=yes');
}
</script>
You can use Jquery popup window plugin it is easy to use and more flexible also.
http://swip.codylindley.com/popupWindowDemo.html
On site you are referring to, browser window is opened. It's configured so that it does not have toolbar, status bar, menu bar, etc.
You can take a look at window opening code in HTML source of the page you are referring to:
<a onClick="window.open(this,'playsample','width=900,height=790,scrollbars=yes,dependent=yes,toolbar=no,location=no,status=no,directories=no,menubar=no,status=no,resizable=yes');return false;">
Is javascript an option?
With javascript it would be something like this:
<a href="#" onclick="window.open('blahblah.aspx', 'game','status=0,toolbar=0,width:400,height:300');" > Click here for the game! </a>
Use this
Click me!
Or even better, put the onclick code in a function of your own so you can reuse it.

How Internet Explorer Prepare Print Preview window

I am wondering how Internet Explorer, Mozilla Firefox or any other browser generate print preview window of an web page loaded into the browser.
The preview image will have various changes such as banners and adv are removed, will have white background and black text and etc.
We would like implement similar print preview window using C# WebBrowser control and i don't want to use default browser Print preview feature such as ExecWB command or any other.
Please give us some light on this.
Thanks,
Ramanand Bhat.
You could try to alter the styles by accessing and modifying the HTMLDocument LINK elements.
HtmlDocument document = WebBrowser1.Document;
foreach (HtmlElement element in document.GetElementsByTagName("LINK"))
{
string cssMedia = element.GetAttribute("Media");
if (cssMedia == "print")
element.SetAttribute("Media", "screen"); //sets print styles to display normally
else
element.SetAttribute("Media", "hidden"); //hides normal styles
}
This will change your print-styles to display in screen view (i.e. as a normal stylesheet without having to use the print-preview window) and your screen-styles to not be shown (as they don't have a Media type of screen anymore)
This is sample code so doesn't have any error checking. It might also have some syntax errors but it should be a start to achieve your goal.
To print a screen you need to set up a call to window.print() in javascript.
Print screen
It will then use whatever css you have assigned as 'print' in the page to render the page as a preview
As far as I know, the banners, advertisements, et cetera are not removed by the browser during a print preview. CSS governs the appearance when the media is print.

Closing an IE 'popup' window with script

Is it at all possible to disable the "The webpage you are viewing is trying to close the window. Do you want to close it?"?
I understand that this is the product of years of virus, and malicious script activity, but in legit app code, (ASP.NET), is there any way to like "register" your app as an APP, or flags you can pass to an IE Popup so that it will not display this when it closes?
The code I'm using is done from within the C# code behind:
ClientScript.RegisterClientScriptBlock(GetType(), "save", Utils.MakeScriptBlock("window.close();"));
The Utils.MakeScriptBlock is just a function that does what you might expect. It 'injects' a <script...> tag with the code in it...
It's probably not possible to get around this, or else, all the script kiddies would just use that trick, but I thought I'd ask, as I can't be the ONLY one using simple IE "popups" as (pseudo)modal dialog boxes.
This code happens in my ButtonSave_Click() routine, after everything has passed validation, etc...
** EDIT **
Just for reference, here is the code that OPENS the popup, when the ADD button is clicked:
This is in Page_Init()...
ButtonAdd.Attributes.Add("onclick", "window.open('Add.aspx', 'ADD_WINDOW', 'scrollbars=no,width=550,height=550,location=no,menubar=no,resizable=yes,directories=no,status=no,toolbar=no'); return false;");
You can close the window without the popup if the window was opened by your script. Does that help?
Edit:
You're already opening the window with script. Change your client script to call self.close().
ClientScript.RegisterClientScriptBlock(GetType(), "save", Utils.MakeScriptBlock("self.close();"));
I believe not. As you state to help prevent malware.
In the end the browser does not know that you are not evil. See RFC 3514 for a similar idea.
I highly doubt it's possible on your end - sounds like something a user would have to specifically disable in their IE settings.
If the user opened the browser window, you can't close it; but if the window was opened via script, you can. Sounds like you just need an initial page that the user starts at with a "click here to begin" link, from which you open a new window for the main portion of the site; when they're all done, close the popup and they're left with their initial browser window with the "click here to begin" message.
Bizarre, but I've found that
<script type="text/javascript">
function closeWindow()
{
window.close();
return false;
}
</script>
and then calling
return closeWindow();
usually gets around this.

Categories

Resources