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 6102399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:36:34+00:00 2026-05-23T13:36:34+00:00

I have created a custom server control. So far this control renders some html

  • 0

I have created a custom server control. So far this control renders some html in the webpage. On submit of the page i need to take the values entered in the textbox of the server control and call some webservice to validate the input of the user. i don’t want to write this code in code behind of the page that this control is used in. I want all the validations to be written in the server control itself and if validation fails, Page.IsValid should be set to false. If the user input value in server control is valid Page.IsValid will be true.

I am trying to achieve is the same functionality as google recaptcha. All user needs to do to use this control is to user the control in the page. user entered value is correct or incorrect is handled in the control itself and in the code behind of the page, there is only Page.IsValid. Here is the page on google that explains this

http://code.google.com/apis/recaptcha/docs/aspnet.html

and i have also used the google recaptcha and it works as expected. I also want to build same kind of functionality for my server control, Please help, if it is possible.

  • 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-05-23T13:36:35+00:00Added an answer on May 23, 2026 at 1:36 pm

    Thank’s for answering the questions. I found the solution. Here is the entire code of the server control. The trick was to implement IValidator. It gives us two property and one metod. ErrorMessage and IsValid properties and Validate method. I wrote all the validation code in Validate method and set this.IsValid. This solved the problem.

    [ToolboxData("<{0}:MyControl runat=server></{0}:MyControl>")]
    public class MyControl : WebControl, IValidator
    {
        protected override void RenderContents(HtmlTextWriter output)
        {
            //Render the required html
        }
    
        protected override void Render(HtmlTextWriter writer)
        {
            this.RenderContents(writer);
        }
    
        protected override void OnInit(EventArgs e)
        {
            Page.Validators.Add(this);
            base.OnInit(e);
        }
    
        public string ErrorMessage
        {
            get;
            set;
        }
    
        public bool IsValid
        {
            get;
            set;
        }
    
        public void Validate()
        {
            string code = Context.Request["txtCode"];
            this.IsValid = Validate(code);//this method calls the webservice and returns true or false
            if (!this.IsValid)
            {
                ErrorMessage = "Invalid Code";
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a custom Server control that processes some data, stores that data
I have created a custom server control with properties implementing the ITemplate interface. It
I have a my own custom web server control. I created separate CSS file
I have created a custom server control, deriving from System.Web.Contols.CheckBoxList to customize how a
I have a custom server control (composite control having dynamically created dropdown boxes and
I have created a custom control which uploaded files to the server . These
I have a site hosted on an Apache server. I have created some custom
I have created a custom server control that inherits from CompositeControl. In the CreateChildControls
I have created a simple Asp.Net custom control which automatically combines all the correct
I have written a custom server control which (pseudo-code) looks like public class MyCustomCtrl

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.