|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
OnServerValidate handler - how to know which CustomValidator is using it ?Hi - I have set up a number of CustomValidators all of which specify
the same method as on their 'OnServerValidate' property. Within the method handling the custom validation how can I determine which CustomValidator is calling ? I would like to modify the error message dynamically but without knowing whihc CustomValidator is firing I cannot. Any ideas ? Richard. Try using the sender parameter
Show quoteHide quote "northof40" <shearich***@gmail.com> wrote in message news:1193382105.477436.81820@q3g2000prf.googlegroups.com... > Hi - I have set up a number of CustomValidators all of which specify > the same method as on their 'OnServerValidate' property. > > Within the method handling the custom validation how can I determine > which CustomValidator is calling ? > > I would like to modify the error message dynamically but without > knowing whihc CustomValidator is firing I cannot. > > Any ideas ? > > Richard. > On Oct 30, 9:47 am, "Nathan Sokalski" <njsokal***@hotmail.com> wrote: Thanks for your reply - I'm not quite sure what you mean though.When I look at source.ToString() I get ... "System.Web.UI.WebControls.CustomValidator" .... which doesn't tell me which CustomValidator is causing the handler to fire. Maybe I misunderstood what you meant - could you expand on it ? Thanks Richard. Show quoteHide quote > Try using the sender parameter > -- > Nathan Sokalski > njsokal...@hotmail.comhttp://www.nathansokalski.com/ > > "northof40" <shearich***@gmail.com> wrote in message > > news:1193382105.477436.81820@q3g2000prf.googlegroups.com... > > > Hi - I have set up a number of CustomValidators all of which specify > > the same method as on their 'OnServerValidate' property. > > > Within the method handling the custom validation how can I determine > > which CustomValidator is calling ? > > > I would like to modify the error message dynamically but without > > knowing whihc CustomValidator is firing I cannot. > > > Any ideas ? > > > Richard. Try casting source as a CustomValidator, and then getting the ID attribute,
like the following (the following is VB.NET code): CType(source,System.Web.UI.WebControls.CustomValidator).ID Because source is an Object, you must first convert it to the correct type. Then use the ID property to determine which of the validators it is. If this does not work, it may help if you could send us your code so that we can see exactly what techniques you are using. Show quoteHide quote "northof40" <shearich***@gmail.com> wrote in message news:1193881163.973946.10980@k35g2000prh.googlegroups.com... > On Oct 30, 9:47 am, "Nathan Sokalski" <njsokal***@hotmail.com> wrote: > Thanks for your reply - I'm not quite sure what you mean though. > > When I look at source.ToString() I get ... > > "System.Web.UI.WebControls.CustomValidator" > > ... which doesn't tell me which CustomValidator is causing the handler > to fire. Maybe I misunderstood what you meant - could you expand on > it ? > > Thanks > > Richard. > > > >> Try using the sender parameter >> -- >> Nathan Sokalski >> njsokal...@hotmail.comhttp://www.nathansokalski.com/ >> >> "northof40" <shearich***@gmail.com> wrote in message >> >> news:1193382105.477436.81820@q3g2000prf.googlegroups.com... >> >> > Hi - I have set up a number of CustomValidators all of which specify >> > the same method as on their 'OnServerValidate' property. >> >> > Within the method handling the custom validation how can I determine >> > which CustomValidator is calling ? >> >> > I would like to modify the error message dynamically but without >> > knowing whihc CustomValidator is firing I cannot. >> >> > Any ideas ? >> >> > Richard. > >
PostBackTrigger for Ajax cannot find FormView Button
BulletedList Control unhandled exception in custom web control (PS:PSGridView) Position of a dynamic table DropDownList in a GridView RequiredFieldvalidator displays error too early How to make to RadioButtonList on the same group use index on dropdownlist Help with vb.net Maths syntax in asp.net Menu Control used on a MasterPage |
|||||||||||||||||||||||