简体   繁体   English

如何使用C#语言关闭Webform?

[英]How to close a webform IN C# LANGUAGE?

I simply want to close an aspx Web Form (that is to say to CLOSE THE CORRENT WINDOW). 我只想关闭一个aspx Web窗体(也就是说,关闭当前窗口)。

I saw a lot of explanations that use a Response.Write with Javascript code, but I will not use 我看到了很多使用Response.Write和Javascript代码的解释,但我不会使用

them, because I want to know if the C# language offer the possibility itself to close a Web 他们,因为我想知道C#语言是否本身提供了关闭Web的可能性

Form. 形成。

QUESTION: How can I close a Web Form with C# code? 问题:如何使用C#代码关闭Web窗体?

That's not possible. 那不可能 C# runs on your server, JavaScript on your client. C#在服务器上运行,JavaScript在客户端上运行。 So the only suitable solution (I'm aware of) is to send a JavaScript close to the client. 因此(我知道)唯一合适的解决方案是向客户端close发送JavaScript。

Your C# runs only on the server. 您的C# 在服务器上运行。 It spits out HTML (and maybe JavaScript), then it's done. 它吐出HTML(也许还有JavaScript),然后就完成了。 There's no way to close a window without JavaScript. 没有JavaScript,就无法关闭窗口。 At most, you might find a C# method that outputs the window.close JavaScript for you. 最多,您可能会找到一个C#方法来为您输出window.close JavaScript。 That doesn't buy you much, though. 不过,那买不了多少钱。

You can't. 你不能

C# is used as a server programming language in ASP.NET C#在ASP.NET中用作服务器编程语言

C# runs on the web server that has nothing to do with your browser. C#在与您的浏览器无关的Web服务器上运行。 To close the browser window you should use a clientside language like javascript. 要关闭浏览器窗口,您应该使用javascript之类的客户端语言。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM