|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
validating user controlI have a user control which is made up of an Infragistics web date chooser and a text box. What I would like to do is validate the date selected in the web date chooser using a required field validator and also a range validator control. I have tried doing this but when setting the ControlToValidate property to the user control I get an error stating the control referenced by ControlToValidate cannot be validated Is there a way for me to enable this user control to be validated using the ..net validator controls? I have looked very hard on the net for articles and help but I could not find much on this topic. Thanks Lewis Holmes eNate Hi Lewis,
Welcome to the ASPNET newsgroup. As fro the making ASP.NET usercontrol(ascx ?) be validated by the built-in validation controls, based on my understanding, so far we can extend our own server controls to be validatable by built-in server controls through server-side validation. To do this, we should expose a certain public property which associate to the data in our control (need to validate by other validators). Then, use the ValidationPropertyAttribute to decorate that property on the control: #How to extend a Web form control to work with the validation controls by using Visual C# http://support.microsoft.com/kb/310145/en-us also, this is mainly used for custom server control rather than usercontrol. For your scenario, we need to define a custom property on the usercontrol to expose the inner control's property(which need valdation). e.g; [ValidationProperty("ImageUrl")] public partial class UserControls_HelloUCl : System.Web.UI.UserControl { public string ImageUrl { get { return txtInput.Text; } set { txtInput.Text = value; } } protected void Page_Load(object sender, EventArgs e) { Label1.Text = ImageUrl; } } And on the ASP.NET page, the design-time "ControlToValidate" dropdown won't automatically popultae the usercontrol in the list, we need to manually input the usercontrol's ID into the field (Make sure the usercontrol is in the same naming container with the validator, otherwise, the validator can not find it at runtime). Hope this helps. Regards, Steven Cheng Microsoft Online Community Support ================================================== When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue. ================================================== This posting is provided "AS IS" with no warranties, and confers no rights. Get Secure! www.microsoft.com/security (This posting is provided "AS IS", with no warranties, and confers no rights.)
"Cannot have multiple items selected in a DropDownList" Error
How to get ListItemValue and ListItemText from a Combo using SendMessage edit attribute values of a web control just before control rendered to the page (control's Load even clicked event never fires Atlas UpdatePanel with Webparts events inheritance RE: Checkbox data binding on Checked property Accessing FormView template controls Problems with dynamically created GridView/DetailsView Rendering a Treeview Control |
|||||||||||||||||||||||