Solved

Validating  custom control

Posted on 2008-06-24
5
805 Views
Last Modified: 2012-08-14
Hi,
1) I am developing a custom control containing textboxes. I want to use required field, reg expression and compare validation controls to check  custom control's textbox inputs.
2)Also when i will use custom control in .aspx web page. It will use validation summary control of the .aspx web page to display validation error message.
Please help me out in this case    
Cheers
0
Comment
Question by:Manusmrati
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 12

Expert Comment

by:madhevan_pillai
ID: 21854190
Hi

try this. go thru ValidationProperty("Text")]


using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;


[DefaultProperty("Text"), ToolboxData("<{0}:Textvalidator runat=server></{0}:Textvalidator>"), ValidationProperty("Text")]
public class Textvalidator : WebControl, INamingContainer
{
   
    TextBox t;
    Button b;
    protected override void OnInit(EventArgs e)
    {
        t = new TextBox();
        b = new Button();
        this.Controls.Add(t);
        this.Controls.Add(b);
    }
   
    [Bindable(true), Category("Appearance"), DefaultValue(""), Localizable(true)]
    public string Text {

        get { return t.Text; }
       
        set { t.Text = value; }
    }
   
}
0
 

Author Comment

by:Manusmrati
ID: 21854398
Hi

Thanks for your reply, Actually Its a Common fields Address custom control with textboxes and labels. I have a provision to diable textboxes and lable at run time, So you can custamize it according to your need.Till that time, i am rendering the textboxes using override render method. I am not creating an instance of the textbox which you used in your above mentioned code. Is there a way i can add client side validation using embedded javascript file.  I think if you rendering a control , client side validation is the best solution.
Or
I would go for creating a instance of the texboxes and label and individually go for ValidationPropertyAttribute check .
Suggestions are welcomed.
Cheers

need your view point.
Cheers
0
 
LVL 12

Accepted Solution

by:
madhevan_pillai earned 250 total points
ID: 21855424
Instance method is the best one. You can directly bind  the custom control to validation controls.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question