如何从类库中的类内部显示消息框?
谁能告诉我如何在 c# 中的类库项目的 .cs 文件中显示警报消息?
我正在类库项目中调用cs文件的方法。每当控件到达方法内的警报消息语句时,警报消息都应显示在网页(aspx)上,并且不应执行警报消息语句的下一条语句。
Can anyone tell me how to show alert message inside the .cs file of class library project in c#?
I am calling a method of cs file in classlibrary project. Whenever the control comes to the alert message statement inside the method, alert message should be shown on the web page(aspx) and the next statement to the alert message statement should not be executed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
请小心不要在类库中放入过多的 UI 代码。听起来你的类库方法应该抛出异常。然后调用代码可以捕获异常并根据需要将其显示给用户。
Be careful about putting too much UI code in your class libraries. It sounds like your class library method should throw an exception. Then the calling code can trap the exception and display it to the user as needed.
在由明确定义的层组成的应用程序中,永远不应该这样做。
这个问题缺乏关于您试图通过这样做来完成什么的细节,但这里有一些可能性和解决方案:
In an application made of well-defined tiers, this should never be done.
There is a lack of detail in the question as to what you're trying to accomplish by doing this, but here are a few possibilities and solutions:
您的类库方法应该将错误返回给调用者,并且由调用者决定是否应该显示错误。
Your class library method should return the error to the caller, and it's up to the caller whether the error should be shown or not.