Custom Server Control Does Not Cause Validation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KarlCharlotteNc

    Custom Server Control Does Not Cause Validation

    I have a custom server control that renders a Submit button.

    The button renders just fine at design and run time.
    The button click event is being trapped normally.

    My problem : If I add a textbox and a required field validator, my button does not cause either the normal client or server side validation to occur.

    Is there a method I must call or an interface I must implement to get my custom control wired up on the Page like a normal Button control. A normal button gets the OnClick Javascript added automatically when rendered if a validation control is no the page. In addition a normal Button control causes the Page.Validate method to run.

    Thank you so much for your help,

    Karl
  • Peter Blum

    #2
    Re: Custom Server Control Does Not Cause Validation

    In your rendered HTML for the button, create an onclick attribute with the
    text from the Page.GetPostBac kEventReference . The only concern is that this
    method may need to be called during the OnPreRender phase. Its probably too
    late to call it in Render. If you are using Render to create the button's
    HTML, call GetPostBackEven tReference in OnPreRender and save the string in a
    field until Render.

    --- Peter Blum

    Email: PLBlum@PeterBlu m.com
    Creator of "Profession al Validation And More" at


    "KarlCharlotteN c" <anonymous@disc ussions.microso ft.com> wrote in message
    news:D924C155-491B-450E-AE73-5EBCEDE3882D@mi crosoft.com...[color=blue]
    > I have a custom server control that renders a Submit button.
    >
    > The button renders just fine at design and run time.
    > The button click event is being trapped normally.
    >
    > My problem : If I add a textbox and a required field validator, my button[/color]
    does not cause either the normal client or server side validation to occur.[color=blue]
    >
    > Is there a method I must call or an interface I must implement to get my[/color]
    custom control wired up on the Page like a normal Button control. A normal
    button gets the OnClick Javascript added automatically when rendered if a
    validation control is no the page. In addition a normal Button control
    causes the Page.Validate method to run.[color=blue]
    >
    > Thank you so much for your help,
    >
    > Karl[/color]


    Comment

    • bruce barker

      #3
      Re: Custom Server Control Does Not Cause Validation

      because you are rendering the html, you have to add the javascript call
      yourself.

      -- bruce (sqlwork.com)


      "KarlCharlotteN c" <anonymous@disc ussions.microso ft.com> wrote in message
      news:D924C155-491B-450E-AE73-5EBCEDE3882D@mi crosoft.com...[color=blue]
      > I have a custom server control that renders a Submit button.
      >
      > The button renders just fine at design and run time.
      > The button click event is being trapped normally.
      >
      > My problem : If I add a textbox and a required field validator, my button[/color]
      does not cause either the normal client or server side validation to occur.[color=blue]
      >
      > Is there a method I must call or an interface I must implement to get my[/color]
      custom control wired up on the Page like a normal Button control. A normal
      button gets the OnClick Javascript added automatically when rendered if a
      validation control is no the page. In addition a normal Button control
      causes the Page.Validate method to run.[color=blue]
      >
      > Thank you so much for your help,
      >
      > Karl[/color]


      Comment

      Working...