从resouce文件asp.net传递错误消息 [英] Pass error message from resouce file asp.net

查看:84
本文介绍了从resouce文件asp.net传递错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中使用企业库.我想从资源文件传递错误消息.

如何将资源文件消息传递到class(test.cs)页面.



施主.cs(页面)

I am using Enterprise library in my application. I want to pass error message from resource file.

How to pass resouce file message to class(test.cs) page.



donor.cs (page)

[Required(ErrorMessage="City Name Cannot be empty")]

        public string CityName
        {
            get { return _cityName; }
            set { _cityName = value; }
        }



我想从资源文件中获取此错误消息,

我的Resource1.resx页面包含

名称:city.text

值:城市名称不能为空


我已经尝试过[Required(ErrorMessage = Resource1.city.text)]

但这不起作用

这是我的实体类.



I want to get this error message from resource file,

my Resource1.resx page contains

Name : city.text

value : City Name Cannot be empty


I have tried [Required(ErrorMessage=Resource1.city.text)]

but this is not working

This is my entity class.

推荐答案

它简单而直接地从资源文件中提取文本.

你试过了吗?网上有各种示例,介绍如何定义资源文件并在您的应用程序中使用它们,其中有两个:
在ASP.NET中使用资源文件 [ ASP.NET 2.0中的资源文件 [ ^ ]
It''s simple and direct pickup of text from resource file.

Did you try? There are various sample on net on how to define a resource file and use it in your application, couple of them:
Using Resource Files In ASP.NET[^]
Resource Files in ASP.NET 2.0[^]


这篇关于从resouce文件asp.net传递错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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