Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8456361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:31:47+00:00 2026-06-10T12:31:47+00:00

I would like to load the ErrorMessage for my CustomValidator from a resource file.

  • 0

I would like to load the ErrorMessage for my CustomValidator from a resource file.

I have my CustomValidator set up like so:

<asp:CustomValidator ID="cv1" runat="server" ControlToValidate="txt1" 
        ErrorMessage="TEXT TO BE LOCALIZED" OnServerValidate="cv1_Validate" />

And my validation method is as follows:

protected void cv1_Validate(object source, ServerValidateEventArgs e)
{
    if (FalseCondition)
    {
        e.IsValid = false;
    }
    else
    {
        e.IsValid = true;
    }
}

The validation works correctly, but I would like to have the ErrorMessage be pulled from my local resources file.

EDIT: I’m also curious if there is any way to do this using meta:resourcekey.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:31:49+00:00Added an answer on June 10, 2026 at 12:31 pm

    Assuming you have a local resource for your page (or control), this would be the way to do it

    ErrorMessage="<%$ resources:ResourceName %>"
    

    In case you get the text from a global resource file you should do something like this

    ErrorMessage="<%$ resources:Strings, ResourceName %>"
    

    Where Strings is the name of the file. This approach is called explicit localization.

    EDIT

    You can use meta:resourcekey. This is called implicit localization. You’ll need to have local resources since this approach is not valid for global resources.

    1. Make sure that you have local resource files (.resx files) that meet the following criteria:

      • They are in an App_LocalResources folder.

      • The base name matches the page name.

      For example, if you are working with the page named Default.aspx, the resource files are named Default.aspx.resx (for the default resources), Default.aspx.es.resx, Default.aspx.es-mx.resx, and so on.

      • The resources in the file use the naming convention resourcekey.”property”.

      For example, key name Button1.”Text”.

    2. In the control markup, add an implicit localization attribute.

      For example:

      <asp:Button ID=”Button1″ runat=”server” Text=”DefaultText”
      meta:resourcekey=”Button1″ />

    Source: MSDN

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an assembly I would like to load from a sub-folder of the
I have the following control: <asp:TextBox ID=textbox1 runat=server Width=95px MaxLength=6 /> which i would
I would like to load some data stored in a file into my mysql
$('#selector').click(function() { // here I would like to load a javascript file // let's
I have requirement where some times I would like to load children as well
I have several PDF templates that I would like to load and modify and
I have a C# .Net 2.0CF application where I would like to load a
I have been toying with the modulino perl pattern and would like to load
I would like to store and load numpy arrays from binary files. For that
I would like to load an image from a directory ../MyAppFolder/Logos. My code: Bitmap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.