Validating two usercontrols


23-Feb-2020 21:11

Is it possible to access this control in a javascript function? Right now I have defined a javascript function called Is Valid() on the page containing the usercontrol with the textbox I would like to validate. If you get the Clientid of a control you can easily write Javascript functions for that control ( on the page or usercontrol as you like) Here is a javascript function to get the client Id of a control Anzer: Thanks for the technique. Your example works nicely if textbox 'txt Name' is on the current page.

Inside of this function I would like to check the value of this textbox somehow. The main problem with writing Javascript for controls inside Usercontrol or Datagrid is you cant directly get the client id of controls to validate. It took me a little bit to figure out that if 'txt Name' is on a usercontrol called My Usr Ctrl1, then I should call Get Client Id("My Usr Ctrl1_txt Name").

A User Control itself cannot be validated because it doesn't generate any HTML. Professional Validation And More lets you assign the control object as an alternative to the ID. Notice that there isn't a Control To Validate property.

You need a control inside it (like that Drop Down List) to validate. Control To Validate property to the ID of the Drop Down List (or whatever data entry control you are evaluating.) Unforunately, Microsoft built the Validators so that the Control To Validate property allows the other control only in the same naming container. So a validator outside the User Control cannot assign the ID of any control within it. When you do, you can have the validator in a different naming container. Bob Gibilaro I want the Property "My Property Is AText Box" to be the validation property? : [Validation Property Attribute("My Property Is AText Box-Text")] Or what? And do you know about exactly what the colon is doing here ? You are mimicking the format of the Unique ID, which is a list of IDs of all naming containers above the control, plus the control itself, separated by a special character.

validating two usercontrols-55

Chat with sexsy girls for free without registering

I would like to validate a textbox on a usercontrol using javascript when the user clicks a button.

Regards, Variable Hi, Can i call any of this function in the text box event, for example i have HTML textbox, in Key Press event can i call this function, i have requirement to validate the texbox to numbers only, if yes how can i can any body suggest me. You are right Anzer: I was totally missing the main point.