如何在C#ASP.NET类.cs文件中显示消息框对话框? [英] How to show message box dialog in C# ASP.NET class .cs file?

查看:583
本文介绍了如何在C#ASP.NET类.cs文件中显示消息框对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨..

我正在将我的项目转换为3层架构,请问我是如何在asp.net c#Class .cs file.I中显示消息对话框的。有一个dataservice calss库,我怎样才能在课堂上显示消息框



我尝试了什么:



我在aspx.cs文件中尝试这个很好用,这里是javascript代码

Hi..
I'm converting my project into 3 layer architecture ,bu I'm stuck here that how can i show message dialog box in asp.net c# Class .cs file.I have a dataservice calss library,How can i show message box in class

What I have tried:

I try this in aspx.cs file its working well,here is javascript code

Response.write(<"Script>alert('Welcome')</Script>");



但是当我在类.cs文件中尝试但它不工作时。我想在这里显示消息框对话框:dataservice.cs文件


but when i try in class .cs file but its not working.I want to show message box dialog here: dataservice.cs file

if (resultObj != null)
{
   int.TryParse(resultObj.ToString(), out databaseID);
   //SHOW MESSAGEBOX HERE 


}

推荐答案

JavaScript alert 是一个坏主意。它充其量只是作为开发过程中使用的临时工具,但很难灵活,并且对于生产质量代码来说足够好看。如果你想要一些基本的东西,这是好的。



也许最好的想法是一些设施统称为模态弹出窗口;最受欢迎的实现之一是 jQuery Dialog ,但还有更多其他实现;其中许多是第三方jQuery UI插件,具有许多效果,如过渡,尤其是调光。其他JavaScript库中也有类似的模型。基本上,这些产品在同一个Web页面上模拟某个特定意义上的模态行为,这是一个很大的好处:没有弹出窗口,浏览器中没有任何内容阻止这种行为。



请阅读我的主题文章: 从零开始的模态弹出



我不仅提供自己的全功能产品,而且还解释了概念,工作原理,并解释了所有产品的基本原理。各种这样的弹出窗口,所以你可以自己决定使用什么,或者自己开发。



参见:Modal popup



-SA
JavaScript alert is a bad idea. It's fine, at best, as a temporary tool used during development process, but hardly flexible enough and good looking enough for the code of production quality. This is good if you want something rudimentary.

Perhaps the best idea would be some facility collectively known as "modal pop-up"; one of the most popular implementation is jQuery Dialog, but there are much more other implementations; many of them are 3rd-party jQuery UI plug-ins, featuring many effects, like transitional, and, notably, dimming. There are similar "models" in other JavaScript libraries. Basically, such products emulate modal behavior, in certain specific sense of this word, on the same Web page, which is a big benefit: there are no pop-up windows, nothing in the browser blocks such behavior.

Please read my article on the topic: Modal Popup From Scratch.

Not only I offer my own fully-functional product, but I also explain the conceptions, how it works, and explain the rationale behind all kinds of such "pop-ups", so you can decide what to use by yourself, or develop your own.

See also: Modal popup.

—SA


如果您希望在继续编码之前获得某种确认或警报,那么您将不得不将您的流程分成两部分,前半部分将导致html页面正在显示给将显示警报并具有继续其余过程的方法的用户。这样做的一些例子如下:



要求用户确认他们想要继续进行操作ASP.NET论坛 [ ^ ]
If you're looking to get some kind of confirmation, or an alert before you continue your code then you're going to have to split your process in two, the first half will result in an html page being shown to the user that will show the alert and have a method to continue with the rest of the process. Some examples of doing this are below

Asking the user to confirm that they want to continue with an action | The ASP.NET Forums[^]


请参阅我今天早些时候回答的类似问题。



在ASP.NET webform项目中显示错误/异常消息。-CodeProject [ ^ ]

让我知道它是否有帮助。
Refer this similar question which i have answered earlier today.

Show error/exception message in ASP.NET webform project.-CodeProject[^]
let me know if it helps.


这篇关于如何在C#ASP.NET类.cs文件中显示消息框对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆