How do I stop this javascript from being emitted?

Discussion in 'ASP .Net Building Controls' started by paul.hester@gmail.com, Sep 15, 2006.

  1. Guest

    Hi all,

    I have a fairly basic page with some text boxes, validators and submit
    buttons. I have "EnableClientScript" set to false for all the
    validators and "enableEventValidation" set to false in the pages
    section of the web.config file. Whenever a validator is present on the
    page, the following javascript is emitted:

    <script type="text/javascript">
    <!--
    var theForm = document.forms['aspnetForm'];
    if (!theForm) {
    theForm = document.aspnetForm;
    }
    function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
    theForm.__EVENTTARGET.value = eventTarget;
    theForm.__EVENTARGUMENT.value = eventArgument;
    theForm.submit();
    }
    }
    // -->
    </script>

    <script
    src="/WebResource.axd?d=yCWeX6Nxz-J5KFaiENoCPA2&amp;t=632938428474843750"
    type="text/javascript"></script>

    If I remove the validators, it's not emitted. I've decoded the
    viewstate and it contains the following items:

    -1017253366d
    __ControlsRequirePostBackKey__
    ctl00$cphPage$ctl01
    ctl00$cphPage$ctl02R

    Does anyone know what I can do to stop the javascript being emitted?

    Thanks,

    Paul
     
    , Sep 15, 2006
    #1
    1. Advertising

  2. Teemu Keiski Guest

    I think it is the Button causing it to be registered when there are
    validators in the same validation group with it.

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke

    <> wrote in message
    news:...
    > Hi all,
    >
    > I have a fairly basic page with some text boxes, validators and submit
    > buttons. I have "EnableClientScript" set to false for all the
    > validators and "enableEventValidation" set to false in the pages
    > section of the web.config file. Whenever a validator is present on the
    > page, the following javascript is emitted:
    >
    > <script type="text/javascript">
    > <!--
    > var theForm = document.forms['aspnetForm'];
    > if (!theForm) {
    > theForm = document.aspnetForm;
    > }
    > function __doPostBack(eventTarget, eventArgument) {
    > if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
    > theForm.__EVENTTARGET.value = eventTarget;
    > theForm.__EVENTARGUMENT.value = eventArgument;
    > theForm.submit();
    > }
    > }
    > // -->
    > </script>
    >
    > <script
    > src="/WebResource.axd?d=yCWeX6Nxz-J5KFaiENoCPA2&amp;t=632938428474843750"
    > type="text/javascript"></script>
    >
    > If I remove the validators, it's not emitted. I've decoded the
    > viewstate and it contains the following items:
    >
    > -1017253366d
    > __ControlsRequirePostBackKey__
    > ctl00$cphPage$ctl01
    > ctl00$cphPage$ctl02R
    >
    > Does anyone know what I can do to stop the javascript being emitted?
    >
    > Thanks,
    >
    > Paul
    >
     
    Teemu Keiski, Sep 16, 2006
    #2
    1. Advertising

  3. Guest

    Hi Teemu,

    Thanks for getting back to me. Do you know how I can stop this from
    happening?

    Thanks,

    Paul

    Teemu Keiski wrote:
    > I think it is the Button causing it to be registered when there are
    > validators in the same validation group with it.
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    > http://blogs.aspadvice.com/joteke
    >
    > <> wrote in message
    > news:...
    > > Hi all,
    > >
    > > I have a fairly basic page with some text boxes, validators and submit
    > > buttons. I have "EnableClientScript" set to false for all the
    > > validators and "enableEventValidation" set to false in the pages
    > > section of the web.config file. Whenever a validator is present on the
    > > page, the following javascript is emitted:
    > >
    > > <script type="text/javascript">
    > > <!--
    > > var theForm = document.forms['aspnetForm'];
    > > if (!theForm) {
    > > theForm = document.aspnetForm;
    > > }
    > > function __doPostBack(eventTarget, eventArgument) {
    > > if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
    > > theForm.__EVENTTARGET.value = eventTarget;
    > > theForm.__EVENTARGUMENT.value = eventArgument;
    > > theForm.submit();
    > > }
    > > }
    > > // -->
    > > </script>
    > >
    > > <script
    > > src="/WebResource.axd?d=yCWeX6Nxz-J5KFaiENoCPA2&amp;t=632938428474843750"
    > > type="text/javascript"></script>
    > >
    > > If I remove the validators, it's not emitted. I've decoded the
    > > viewstate and it contains the following items:
    > >
    > > -1017253366d
    > > __ControlsRequirePostBackKey__
    > > ctl00$cphPage$ctl01
    > > ctl00$cphPage$ctl02R
    > >
    > > Does anyone know what I can do to stop the javascript being emitted?
    > >
    > > Thanks,
    > >
    > > Paul
    > >
     
    , Sep 16, 2006
    #3
  4. Teemu Keiski Guest

    Set CausesValidation="False" for the Button in the same validation group.
    You just need to call Page.Validate on server manually before you can access
    Page.IsValid property.

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke

    <> wrote in message
    news:...
    > Hi Teemu,
    >
    > Thanks for getting back to me. Do you know how I can stop this from
    > happening?
    >
    > Thanks,
    >
    > Paul
    >
    > Teemu Keiski wrote:
    >> I think it is the Button causing it to be registered when there are
    >> validators in the same validation group with it.
    >>
    >> --
    >> Teemu Keiski
    >> ASP.NET MVP, AspInsider
    >> Finland, EU
    >> http://blogs.aspadvice.com/joteke
    >>
    >> <> wrote in message
    >> news:...
    >> > Hi all,
    >> >
    >> > I have a fairly basic page with some text boxes, validators and submit
    >> > buttons. I have "EnableClientScript" set to false for all the
    >> > validators and "enableEventValidation" set to false in the pages
    >> > section of the web.config file. Whenever a validator is present on the
    >> > page, the following javascript is emitted:
    >> >
    >> > <script type="text/javascript">
    >> > <!--
    >> > var theForm = document.forms['aspnetForm'];
    >> > if (!theForm) {
    >> > theForm = document.aspnetForm;
    >> > }
    >> > function __doPostBack(eventTarget, eventArgument) {
    >> > if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
    >> > theForm.__EVENTTARGET.value = eventTarget;
    >> > theForm.__EVENTARGUMENT.value = eventArgument;
    >> > theForm.submit();
    >> > }
    >> > }
    >> > // -->
    >> > </script>
    >> >
    >> > <script
    >> > src="/WebResource.axd?d=yCWeX6Nxz-J5KFaiENoCPA2&amp;t=632938428474843750"
    >> > type="text/javascript"></script>
    >> >
    >> > If I remove the validators, it's not emitted. I've decoded the
    >> > viewstate and it contains the following items:
    >> >
    >> > -1017253366d
    >> > __ControlsRequirePostBackKey__
    >> > ctl00$cphPage$ctl01
    >> > ctl00$cphPage$ctl02R
    >> >
    >> > Does anyone know what I can do to stop the javascript being emitted?
    >> >
    >> > Thanks,
    >> >
    >> > Paul
    >> >

    >
     
    Teemu Keiski, Sep 17, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joel Cade
    Replies:
    0
    Views:
    558
    Joel Cade
    Jul 16, 2003
  2. TR
    Replies:
    1
    Views:
    380
    Bruce Barker
    May 24, 2005
  3. Paul
    Replies:
    0
    Views:
    322
  4. David Mathog
    Replies:
    2
    Views:
    351
    Dave Thompson
    Jul 11, 2005
  5. Replies:
    1
    Views:
    107
    gerry
    Sep 15, 2006
Loading...

Share This Page