bypass an event because server side validation failed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • interuser@hotmail.com

    bypass an event because server side validation failed

    Hi
    How can I prevent an event (eg button click) from happening from
    within page_load?
    The reason is that I want to make my existing application work for
    netscape, for which there are no client side validations.
    So I thought to put something like the following in the superclass of
    all UI pages:

    public sub page_load

    me.validate()
    if not me.isvalid() then
    'code to prevent the event to execute goes here.
    end if

    end sub
  • Scott Simons

    #2
    RE: bypass an event because server side validation failed

    check to see if the page is valid in your event handlers.

    Comment

    • Peter Blum

      #3
      Re: bypass an event because server side validation failed

      You have a mistaken idea of how to setup validation. Do NOT attempt to
      validate in Page_Load. Page_Load is run before your post back event handler
      (the button's Click method). The post back event handlers are where you run
      validation. In fact, the button automatically calls Page.Validate() for you
      unless you set its CausesValidatio n property to false.

      You should not attempt to save any data within Page_Load either. So in your
      post back event handler, the following should occur:

      1. Validation. Again its automatically for buttons that have
      CausesValidatio n=true
      2. Check Page.IsValid. If true, save or take whatever action needed on the
      data.

      FYI: You should assume that all browsers will not run the client-side
      validation code. After all, users can turn off javascript in IE. It is
      essential that you write server side validation code always. Microsoft
      designed validation to work that way.

      I have built a replacement to Microsoft's validation, Professional
      Validation And More (http://www.peterblum.com/vam/home.aspx). Its 22
      validators support client-side validation on IE, IE/Mac,
      Netscape/Mozilla/FireFox, Opera 7, and Safari. It overcomes numerous other
      limitations that cause users to write custom code and develop hacks. It
      includes a conversion utility to migrate from Microsoft validators.

      --- Peter Blum

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


      <interuser@hotm ail.com> wrote in message
      news:a840cbfe.0 411010816.532d6 85@posting.goog le.com...[color=blue]
      > Hi
      > How can I prevent an event (eg button click) from happening from
      > within page_load?
      > The reason is that I want to make my existing application work for
      > netscape, for which there are no client side validations.
      > So I thought to put something like the following in the superclass of
      > all UI pages:
      >
      > public sub page_load
      >
      > me.validate()
      > if not me.isvalid() then
      > 'code to prevent the event to execute goes here.
      > end if
      >
      > end sub[/color]


      Comment

      • Enrique Santa Cruz

        #4
        Re: bypass an event because server side validation failed

        Check the page post back in the page load if it's false then the page load
        has triggered on the first page load if it's true then the page load has
        triggered on a post back event.
        if(Page.IsPostB ack != true)
        {
        Globals.Account = true;
        Globals.Navigat ion(this, Globals.Paramet er(this, "mi"),
        Globals.Paramet er(this, "si"), Globals.Paramet er(this, "ni"),
        Globals.Paramet er(this, "ln"));
        this.CurrentCul ture =
        System.Globaliz ation.CultureIn fo.CreateSpecif icCulture(Sessi on["Language"].ToString());
        Browser.Accept = "text/*";
        Menuloader(null );
        Traductor(null) ;
        Visualization(n ull);
        RightPane.Contr ols.Add(Page.Lo adControl("~/controls/search.ascx"));
        string win = "false";
        Rx.Attributes.R emove("onsubmit ");
        Page.RegisterHi ddenField("__EV ENTTARGET", "Submit");
        Rx.Attributes.A dd("onsubmit"," javascript: validation("+ win +");");
        }
        Session["UrlRedirec t"] = Request.Url.ToS tring();
        Enrique.
        <interuser@hotm ail.com> wrote in message
        news:a840cbfe.0 411010816.532d6 85@posting.goog le.com...[color=blue]
        > Hi
        > How can I prevent an event (eg button click) from happening from
        > within page_load?
        > The reason is that I want to make my existing application work for
        > netscape, for which there are no client side validations.
        > So I thought to put something like the following in the superclass of
        > all UI pages:
        >
        > public sub page_load
        >
        > me.validate()
        > if not me.isvalid() then
        > 'code to prevent the event to execute goes here.
        > end if
        >
        > end sub[/color]


        Comment

        Working...