Validator not working when inside UpdatePanel

Discussion in 'ASP .Net' started by Nathan Sokalski, Dec 4, 2009.

  1. I have a new validator (inherits from BaseValidator), but it does not always
    work when it is inside an UpdatePanel. When I use it inside an update panel,
    it works fine until I do the first successful submit. After the first
    successful submit, the validator basically acts as if it is no longer there.
    Why could this be happening? Any help would be appreciated. Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
    Nathan Sokalski, Dec 4, 2009
    #1
    1. Advertising

  2. "Nathan Sokalski" <> wrote in
    news:#:

    > I have a new validator (inherits from BaseValidator), but it does not
    > always work when it is inside an UpdatePanel. When I use it inside an
    > update panel, it works fine until I do the first successful submit.
    > After the first successful submit, the validator basically acts as if
    > it is no longer there. Why could this be happening? Any help would be
    > appreciated. Thanks.


    Having not tried this, my assumption would be that the intiial state is
    changed once the submit is done. This means you need a bit of JavaScript
    to re-activate it.

    To confirm this, I would consider using Firefox with Firebug, or
    similar, to debug the AJAX.

    For IE, you can use Fiddler, but it takes a bit more work as it is an
    "external" tool.

    Peace and Grace,

    --
    Gregory A. Beamer (MVP)

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    *******************************************
    | Think outside the box! |
    *******************************************
    Gregory A. Beamer, Dec 4, 2009
    #2
    1. Advertising

  3. I have never used Firebug or Fiddler before, although I have heard of and
    seen them so I don't expect to have any problem using them. However, because
    my situation does not involve recieving an error, and I do not know exactly
    what is getting changed when I submit, I really don't have any idea where to
    start as far as what to look for. Can you help me get started? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Gregory A. Beamer" <> wrote in message
    news:Xns9CD78EDF2AAF3gbworld@207.46.248.16...
    > "Nathan Sokalski" <> wrote in
    > news:#:
    >
    >> I have a new validator (inherits from BaseValidator), but it does not
    >> always work when it is inside an UpdatePanel. When I use it inside an
    >> update panel, it works fine until I do the first successful submit.
    >> After the first successful submit, the validator basically acts as if
    >> it is no longer there. Why could this be happening? Any help would be
    >> appreciated. Thanks.

    >
    > Having not tried this, my assumption would be that the intiial state is
    > changed once the submit is done. This means you need a bit of JavaScript
    > to re-activate it.
    >
    > To confirm this, I would consider using Firefox with Firebug, or
    > similar, to debug the AJAX.
    >
    > For IE, you can use Fiddler, but it takes a bit more work as it is an
    > "external" tool.
    >
    > Peace and Grace,
    >
    > --
    > Gregory A. Beamer (MVP)
    >
    > Twitter: @gbworld
    > Blog: http://gregorybeamer.spaces.live.com
    >
    > *******************************************
    > | Think outside the box! |
    > *******************************************
    Nathan Sokalski, Dec 5, 2009
    #3
  4. Nathan Sokalski

    bruce barker Guest

    if your validator is in an update panel, then you have to code it
    correctly. your validator is rendered as a span, and will be replaced
    along with any other dom objects in the panel(s). this means you need to
    rerun init code. if it registers any client script, it must use
    ScriptManager to doit. if it references any $gets(), they must be redone.

    -- bruce (sqlwork.com)




    Nathan Sokalski wrote:
    > I have a new validator (inherits from BaseValidator), but it does not always
    > work when it is inside an UpdatePanel. When I use it inside an update panel,
    > it works fine until I do the first successful submit. After the first
    > successful submit, the validator basically acts as if it is no longer there.
    > Why could this be happening? Any help would be appreciated. Thanks.
    bruce barker, Dec 5, 2009
    #4
  5. OK, I think that I have confirmed that is my problem. The init script that I
    need to rerun is a script generated by ASP.NET to set the attributes I add
    when overriding the AddAttributesToRender method inherited from
    BaseValidator. This script looks something like the following:

    var ctl00_cphExampleContent_ctl00 = document.all ?
    document.all["ctl00_cphExampleContent_ctl00"] :
    document.getElementById("ctl00_cphExampleContent_ctl00");
    ctl00_cphExampleContent_ctl00.controltovalidate =
    "ctl00_cphExampleContent_txtMinimum";
    ctl00_cphExampleContent_ctl00.errormessage = "You must enter at least 5
    characters.";
    ctl00_cphExampleContent_ctl00.display = "Dynamic";
    ctl00_cphExampleContent_ctl00.validationGroup = "minimum";

    The script is obviously very simple, but because it is automatically
    generated, how can I rerun it? Also, because this is a validator that I am
    creating to be shared between multiple applications and users, I do not
    actually know whether it will be inside an UpdatePanel or not, so I either
    need to detect that as a condition in the validator or have code that works
    in either scenario. Any ideas? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "bruce barker" <> wrote in message
    news:...
    > if your validator is in an update panel, then you have to code it
    > correctly. your validator is rendered as a span, and will be replaced
    > along with any other dom objects in the panel(s). this means you need to
    > rerun init code. if it registers any client script, it must use
    > ScriptManager to doit. if it references any $gets(), they must be redone.
    >
    > -- bruce (sqlwork.com)
    >
    >
    >
    >
    > Nathan Sokalski wrote:
    >> I have a new validator (inherits from BaseValidator), but it does not
    >> always work when it is inside an UpdatePanel. When I use it inside an
    >> update panel, it works fine until I do the first successful submit. After
    >> the first successful submit, the validator basically acts as if it is no
    >> longer there. Why could this be happening? Any help would be appreciated.
    >> Thanks.
    Nathan Sokalski, Dec 5, 2009
    #5
  6. Nathan Sokalski

    bruce barker Guest

    inline script (writer.write) will not work because when the client
    script in update panel sets the innerHTML, any script in the html is
    ignored by the browser.

    use ScriptManager.RegisterStartupScript to render the script. or as it
    looks like you are only setting properties, use
    ScriptManager.RegisterExpandoAttribute.

    to work with update panels you must use ScriptManager, not the old
    ClientScript.

    -- bruce (sqlwork.com)


    Nathan Sokalski wrote:
    > OK, I think that I have confirmed that is my problem. The init script that I
    > need to rerun is a script generated by ASP.NET to set the attributes I add
    > when overriding the AddAttributesToRender method inherited from
    > BaseValidator. This script looks something like the following:
    >
    > var ctl00_cphExampleContent_ctl00 = document.all ?
    > document.all["ctl00_cphExampleContent_ctl00"] :
    > document.getElementById("ctl00_cphExampleContent_ctl00");
    > ctl00_cphExampleContent_ctl00.controltovalidate =
    > "ctl00_cphExampleContent_txtMinimum";
    > ctl00_cphExampleContent_ctl00.errormessage = "You must enter at least 5
    > characters.";
    > ctl00_cphExampleContent_ctl00.display = "Dynamic";
    > ctl00_cphExampleContent_ctl00.validationGroup = "minimum";
    >
    > The script is obviously very simple, but because it is automatically
    > generated, how can I rerun it? Also, because this is a validator that I am
    > creating to be shared between multiple applications and users, I do not
    > actually know whether it will be inside an UpdatePanel or not, so I either
    > need to detect that as a condition in the validator or have code that works
    > in either scenario. Any ideas? Thanks.
    bruce barker, Dec 5, 2009
    #6
  7. I'm sorry, I think I gave incorrect information in my original post. The
    script does not set the attributes set in AddAttributesToRender, it sets
    several expando attributes used by validators (which, as you could probably
    see, in this case included controltovalidate, errormessage, display, and
    validationGroup). But I think you misunderstood what I meant when I said the
    script is generated by ASP.NET. I am not using ScriptManager OR ClientScript
    directly; the script I showed you is added by the BaseValidator class in
    code that I do not see (or at least I don't know where it is), I believe
    that it is a script that is created regardless of what I do. Because I am
    not the one who writes the code that adds this script, where can I go to fix
    my problem (or is there a function and/or property that returns the script
    that gets generated so that I can rerun the script at the appropriate
    time?)? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "bruce barker" <> wrote in message
    news:%...
    > inline script (writer.write) will not work because when the client script
    > in update panel sets the innerHTML, any script in the html is ignored by
    > the browser.
    >
    > use ScriptManager.RegisterStartupScript to render the script. or as it
    > looks like you are only setting properties, use
    > ScriptManager.RegisterExpandoAttribute.
    >
    > to work with update panels you must use ScriptManager, not the old
    > ClientScript.
    >
    > -- bruce (sqlwork.com)
    >
    >
    > Nathan Sokalski wrote:
    >> OK, I think that I have confirmed that is my problem. The init script
    >> that I need to rerun is a script generated by ASP.NET to set the
    >> attributes I add when overriding the AddAttributesToRender method
    >> inherited from BaseValidator. This script looks something like the
    >> following:
    >>
    >> var ctl00_cphExampleContent_ctl00 = document.all ?
    >> document.all["ctl00_cphExampleContent_ctl00"] :
    >> document.getElementById("ctl00_cphExampleContent_ctl00");
    >> ctl00_cphExampleContent_ctl00.controltovalidate =
    >> "ctl00_cphExampleContent_txtMinimum";
    >> ctl00_cphExampleContent_ctl00.errormessage = "You must enter at least 5
    >> characters.";
    >> ctl00_cphExampleContent_ctl00.display = "Dynamic";
    >> ctl00_cphExampleContent_ctl00.validationGroup = "minimum";
    >>
    >> The script is obviously very simple, but because it is automatically
    >> generated, how can I rerun it? Also, because this is a validator that I
    >> am creating to be shared between multiple applications and users, I do
    >> not actually know whether it will be inside an UpdatePanel or not, so I
    >> either need to detect that as a condition in the validator or have code
    >> that works in either scenario. Any ideas? Thanks.
    Nathan Sokalski, Dec 6, 2009
    #7
  8. Nathan Sokalski

    bruce barker Guest

    the .net validators with 3.5 (webextensions.dll) were rewritten to use
    ScriptManger. I don't know where your validator is from, but you need an
    update panel aware one.

    -- bruce (sqlwork.com)

    Nathan Sokalski wrote:
    > I'm sorry, I think I gave incorrect information in my original post. The
    > script does not set the attributes set in AddAttributesToRender, it sets
    > several expando attributes used by validators (which, as you could probably
    > see, in this case included controltovalidate, errormessage, display, and
    > validationGroup). But I think you misunderstood what I meant when I said the
    > script is generated by ASP.NET. I am not using ScriptManager OR ClientScript
    > directly; the script I showed you is added by the BaseValidator class in
    > code that I do not see (or at least I don't know where it is), I believe
    > that it is a script that is created regardless of what I do. Because I am
    > not the one who writes the code that adds this script, where can I go to fix
    > my problem (or is there a function and/or property that returns the script
    > that gets generated so that I can rerun the script at the appropriate
    > time?)? Thanks.
    bruce barker, Dec 7, 2009
    #8
  9. I am using Visual Studio 2008 and ASP.NET 3.5, and my validator is one that
    I wrote which inherits from BaseValidator (the validator was written using
    Visual Studio 2008 and ASP.NET 3.5 as well). Any more suggestions or ideas?
    Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "bruce barker" <> wrote in message
    news:...
    > the .net validators with 3.5 (webextensions.dll) were rewritten to use
    > ScriptManger. I don't know where your validator is from, but you need an
    > update panel aware one.
    >
    > -- bruce (sqlwork.com)
    >
    > Nathan Sokalski wrote:
    >> I'm sorry, I think I gave incorrect information in my original post. The
    >> script does not set the attributes set in AddAttributesToRender, it sets
    >> several expando attributes used by validators (which, as you could
    >> probably see, in this case included controltovalidate, errormessage,
    >> display, and validationGroup). But I think you misunderstood what I meant
    >> when I said the script is generated by ASP.NET. I am not using
    >> ScriptManager OR ClientScript directly; the script I showed you is added
    >> by the BaseValidator class in code that I do not see (or at least I don't
    >> know where it is), I believe that it is a script that is created
    >> regardless of what I do. Because I am not the one who writes the code
    >> that adds this script, where can I go to fix my problem (or is there a
    >> function and/or property that returns the script that gets generated so
    >> that I can rerun the script at the appropriate time?)? Thanks.
    Nathan Sokalski, Dec 7, 2009
    #9
  10. "Nathan Sokalski" <> wrote in
    news::

    > I have never used Firebug or Fiddler before, although I have heard of
    > and seen them so I don't expect to have any problem using them.
    > However, because my situation does not involve recieving an error, and
    > I do not know exactly what is getting changed when I submit, I really
    > don't have any idea where to start as far as what to look for. Can you
    > help me get started? Thanks.


    Video or text?

    There are quite a few links that talk about debugging AJAX on this
    Google search:
    http://snurl.com/tlfyg

    The top link is a You Tube video that shows how to do it.

    The search (above) is where I would start. if that yields nothing, then
    we can look at other options.

    Peace and Grace,

    --
    Gregory A. Beamer (MVP)

    Twitter: @gbworld
    Blog: http://gregorybeamer.spaces.live.com

    *******************************************
    | Think outside the box! |
    *******************************************
    Gregory A. Beamer, Dec 7, 2009
    #10
  11. Actually, I think I have found the source of the problem, as you will see in
    the response from bruce barker (not that I didn't appreciate yours or plan
    on trying yours also). The problem is the script generated by BaseValidator
    to set some of the expando attributes for the span tag which is the
    validator (such as controltovalidate, errormessage, display,
    validationGroup, etc.). The script works fine, but it needs rerun after the
    UpdatePanel does one of it's asynch postbacks, which I am having trouble
    figuring out how to do, since the script is generated and added completely
    automatically. Any ideas (or if you think the problem could be something
    else)? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Gregory A. Beamer" <> wrote in message
    news:Xns9CDA753184E56gbworld@207.46.248.16...
    > "Nathan Sokalski" <> wrote in
    > news::
    >
    >> I have never used Firebug or Fiddler before, although I have heard of
    >> and seen them so I don't expect to have any problem using them.
    >> However, because my situation does not involve recieving an error, and
    >> I do not know exactly what is getting changed when I submit, I really
    >> don't have any idea where to start as far as what to look for. Can you
    >> help me get started? Thanks.

    >
    > Video or text?
    >
    > There are quite a few links that talk about debugging AJAX on this
    > Google search:
    > http://snurl.com/tlfyg
    >
    > The top link is a You Tube video that shows how to do it.
    >
    > The search (above) is where I would start. if that yields nothing, then
    > we can look at other options.
    >
    > Peace and Grace,
    >
    > --
    > Gregory A. Beamer (MVP)
    >
    > Twitter: @gbworld
    > Blog: http://gregorybeamer.spaces.live.com
    >
    > *******************************************
    > | Think outside the box! |
    > *******************************************
    Nathan Sokalski, Dec 7, 2009
    #11
  12. Nathan Sokalski

    Eric M Guest

    I'm having the exact same issue... That code is not being re-run on
    the asynch post-back, so when I access the property in client code, it
    is undefined.

    On Dec 7, 2:49 pm, "Nathan Sokalski" <> wrote:
    > Actually, I think I have found the source of the problem, as you will see in
    > the response from bruce barker (not that I didn't appreciate yours or plan
    > on trying yours also). The problem is the script generated by BaseValidator
    > to set some of the expando attributes for the span tag which is the
    > validator (such as controltovalidate, errormessage, display,
    > validationGroup, etc.). The script works fine, but it needs rerun after the
    > UpdatePanel does one of it's asynch postbacks, which I am having trouble
    > figuring out how to do, since the script is generated and added completely
    > automatically. Any ideas (or if you think the problem could be something
    > else)? Thanks.
    > --
    > Nathan Sokalski
    > ://www.nathansokalski.com/
    >
    > "Gregory A. Beamer" <> wrote in messagenews:Xns9CDA753184E56gbworld@207.46.248.16...
    >
    >
    >
    > > "Nathan Sokalski" <> wrote in
    > >news::

    >
    > >> I have never used Firebug or Fiddler before, although I have heard of
    > >> and seen them so I don't expect to have any problem using them.
    > >> However, because my situation does not involve recieving an error, and
    > >> I do not know exactly what is getting changed when I submit, I really
    > >> don't have any idea where to start as far as what to look for. Can you
    > >> help me get started? Thanks.

    >
    > > Video or text?

    >
    > > There are quite a few links that talk about debugging AJAX on this
    > > Google search:
    > >http://snurl.com/tlfyg

    >
    > > The top link is a You Tube video that shows how to do it.

    >
    > > The search (above) is where I would start. if that yields nothing, then
    > > we can look at other options.

    >
    > > Peace and Grace,

    >
    > > --
    > > Gregory A. Beamer (MVP)

    >
    > > Twitter: @gbworld
    > > Blog:http://gregorybeamer.spaces.live.com

    >
    > > *******************************************
    > > |      Think outside the box!             |
    > > *******************************************
    Eric M, Dec 9, 2009
    #12
  13. I found some stuff that says there are updated versions of the validators
    for AJAX that fix this, but those posts were from 2007, and not only is this
    over 2 years later, but I did my stuff with ASP.NET 3.5, and I always get
    all the stuff from WindowsUpdate right away (it says the updates will be
    provided through WindowsUpdate). Here is where I got that info:

    http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx

    I don't know if the article is wrong or if I don't have all the updates I
    think I do, but maybe this will help us fix everything. Hopefully.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Eric M" <> wrote in message
    news:...
    I'm having the exact same issue... That code is not being re-run on
    the asynch post-back, so when I access the property in client code, it
    is undefined.

    On Dec 7, 2:49 pm, "Nathan Sokalski" <> wrote:
    > Actually, I think I have found the source of the problem, as you will see
    > in
    > the response from bruce barker (not that I didn't appreciate yours or plan
    > on trying yours also). The problem is the script generated by
    > BaseValidator
    > to set some of the expando attributes for the span tag which is the
    > validator (such as controltovalidate, errormessage, display,
    > validationGroup, etc.). The script works fine, but it needs rerun after
    > the
    > UpdatePanel does one of it's asynch postbacks, which I am having trouble
    > figuring out how to do, since the script is generated and added completely
    > automatically. Any ideas (or if you think the problem could be something
    > else)? Thanks.
    > --
    > Nathan Sokalski
    > ://www.nathansokalski.com/
    >
    > "Gregory A. Beamer" <> wrote in
    > messagenews:Xns9CDA753184E56gbworld@207.46.248.16...
    >
    >
    >
    > > "Nathan Sokalski" <> wrote in
    > >news::

    >
    > >> I have never used Firebug or Fiddler before, although I have heard of
    > >> and seen them so I don't expect to have any problem using them.
    > >> However, because my situation does not involve recieving an error, and
    > >> I do not know exactly what is getting changed when I submit, I really
    > >> don't have any idea where to start as far as what to look for. Can you
    > >> help me get started? Thanks.

    >
    > > Video or text?

    >
    > > There are quite a few links that talk about debugging AJAX on this
    > > Google search:
    > >http://snurl.com/tlfyg

    >
    > > The top link is a You Tube video that shows how to do it.

    >
    > > The search (above) is where I would start. if that yields nothing, then
    > > we can look at other options.

    >
    > > Peace and Grace,

    >
    > > --
    > > Gregory A. Beamer (MVP)

    >
    > > Twitter: @gbworld
    > > Blog:http://gregorybeamer.spaces.live.com

    >
    > > *******************************************
    > > | Think outside the box! |
    > > *******************************************
    Nathan Sokalski, Dec 9, 2009
    #13
  14. Nathan Sokalski

    Jay Woerndle Guest

    Fix for UpdatePanel

    I know this is an old thread, but I just spent 2 days trying to make this work and thought I would save someone else the pain of getting a proper solution. I used older code that I found on the net for a CheckBoxList validator and it worked until the a button was clicked that did an asynchronous update of the updatepanel. The validator I was using also extended the basevalidator class and did an override of the AddAttributesToRender function as well as the OnPreRender function.

    What I did to fix it was to replace code in both functions. In OnPreRender, I replaced
    Page.ClientScript.RegisterStartupScript(GetType(), "evaluationfunction", javascriptString, true);
    with the newer function
    ScriptManager.RegisterStartupScript(this, GetType(), "evaluationfunction", javascriptString, true);

    In AddAttributesToRender I replaced two functions that look like this:
    Page.ClientScript.RegisterExpandoAttribute(this.ClientID, "evaluationfunction", "javascriptFunctionName", false);
    with the newer function
    ScriptManager.RegisterExpandoAttribute(this, this.ClientID, "evaluationfunction", "javascriptFunctionName", false);
    where javascriptFunctionName is the actual name of the javascript function that will be embedded to the aspx page.

    Like Bruce said above, these functions are suited to the UpdatePanel where the old ones were not.


    > On Friday, December 04, 2009 2:41 PM Nathan Sokalski wrote:


    > I have a new validator (inherits from BaseValidator), but it does not always
    > work when it is inside an UpdatePanel. When I use it inside an update panel,
    > it works fine until I do the first successful submit. After the first
    > successful submit, the validator basically acts as if it is no longer there.
    > Why could this be happening? Any help would be appreciated. Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/



    >> On Friday, December 04, 2009 3:04 PM Gregory A. Beamer wrote:


    >> Having not tried this, my assumption would be that the intiial state is
    >> changed once the submit is done. This means you need a bit of JavaScript
    >> to re-activate it.
    >>
    >> To confirm this, I would consider using Firefox with Firebug, or
    >> similar, to debug the AJAX.
    >>
    >> For IE, you can use Fiddler, but it takes a bit more work as it is an
    >> "external" tool.
    >>
    >> Peace and Grace,
    >>
    >> --
    >> Gregory A. Beamer (MVP)
    >>
    >> Twitter: @gbworld
    >> Blog: http://gregorybeamer.spaces.live.com
    >>
    >> *******************************************
    >> | Think outside the box! |
    >> *******************************************



    >>> On Friday, December 04, 2009 9:51 PM Nathan Sokalski wrote:


    >>> I have never used Firebug or Fiddler before, although I have heard of and
    >>> seen them so I do not expect to have any problem using them. However, because
    >>> my situation does not involve recieving an error, and I do not know exactly
    >>> what is getting changed when I submit, I really do not have any idea where to
    >>> start as far as what to look for. Can you help me get started? Thanks.
    >>> --
    >>> Nathan Sokalski
    >>>
    >>> http://www.nathansokalski.com/



    >>>> On Friday, December 04, 2009 10:36 PM bruce barker wrote:


    >>>> if your validator is in an update panel, then you have to code it
    >>>> correctly. your validator is rendered as a span, and will be replaced
    >>>> along with any other dom objects in the panel(s). this means you need to
    >>>> rerun init code. if it registers any client script, it must use
    >>>> ScriptManager to doit. if it references any $gets(), they must be redone.
    >>>>
    >>>> -- bruce (sqlwork.com)
    >>>>
    >>>>
    >>>>
    >>>>
    >>>> Nathan Sokalski wrote:



    >>>>> On Saturday, December 05, 2009 12:48 AM Nathan Sokalski wrote:


    >>>>> OK, I think that I have confirmed that is my problem. The init script that I
    >>>>> need to rerun is a script generated by ASP.NET to set the attributes I add
    >>>>> when overriding the AddAttributesToRender method inherited from
    >>>>> BaseValidator. This script looks something like the following:
    >>>>>
    >>>>> var ctl00_cphExampleContent_ctl00 = document.all ?
    >>>>> document.all["ctl00_cphExampleContent_ctl00"] :
    >>>>> document.getElementById("ctl00_cphExampleContent_ctl00");
    >>>>> ctl00_cphExampleContent_ctl00.controltovalidate =
    >>>>> "ctl00_cphExampleContent_txtMinimum";
    >>>>> ctl00_cphExampleContent_ctl00.errormessage = "You must enter at least 5
    >>>>> characters.";
    >>>>> ctl00_cphExampleContent_ctl00.display = "Dynamic";
    >>>>> ctl00_cphExampleContent_ctl00.validationGroup = "minimum";
    >>>>>
    >>>>> The script is obviously very simple, but because it is automatically
    >>>>> generated, how can I rerun it? Also, because this is a validator that I am
    >>>>> creating to be shared between multiple applications and users, I do not
    >>>>> actually know whether it will be inside an UpdatePanel or not, so I either
    >>>>> need to detect that as a condition in the validator or have code that works
    >>>>> in either scenario. Any ideas? Thanks.
    >>>>> --
    >>>>> Nathan Sokalski
    >>>>>
    >>>>> http://www.nathansokalski.com/



    >>>>>> On Saturday, December 05, 2009 2:08 PM bruce barker wrote:


    >>>>>> inline script (writer.write) will not work because when the client
    >>>>>> script in update panel sets the innerHTML, any script in the html is
    >>>>>> ignored by the browser.
    >>>>>>
    >>>>>> use ScriptManager.RegisterStartupScript to render the script. or as it
    >>>>>> looks like you are only setting properties, use
    >>>>>> ScriptManager.RegisterExpandoAttribute.
    >>>>>>
    >>>>>> to work with update panels you must use ScriptManager, not the old
    >>>>>> ClientScript.
    >>>>>>
    >>>>>> -- bruce (sqlwork.com)
    >>>>>>
    >>>>>>
    >>>>>> Nathan Sokalski wrote:



    >>>>>>> On Sunday, December 06, 2009 4:29 PM Nathan Sokalski wrote:


    >>>>>>> I am sorry, I think I gave incorrect information in my original post. The
    >>>>>>> script does not set the attributes set in AddAttributesToRender, it sets
    >>>>>>> several expando attributes used by validators (which, as you could probably
    >>>>>>> see, in this case included controltovalidate, errormessage, display, and
    >>>>>>> validationGroup). But I think you misunderstood what I meant when I said the
    >>>>>>> script is generated by ASP.NET. I am not using ScriptManager OR ClientScript
    >>>>>>> directly; the script I showed you is added by the BaseValidator class in
    >>>>>>> code that I do not see (or at least I do not know where it is), I believe
    >>>>>>> that it is a script that is created regardless of what I do. Because I am
    >>>>>>> not the one who writes the code that adds this script, where can I go to fix
    >>>>>>> my problem (or is there a function and/or property that returns the script
    >>>>>>> that gets generated so that I can rerun the script at the appropriate
    >>>>>>> time?)? Thanks.
    >>>>>>> --
    >>>>>>> Nathan Sokalski
    >>>>>>>
    >>>>>>> http://www.nathansokalski.com/



    >>>>>>>> On Sunday, December 06, 2009 7:06 PM bruce barker wrote:


    >>>>>>>> the .net validators with 3.5 (webextensions.dll) were rewritten to use
    >>>>>>>> ScriptManger. I do not know where your validator is from, but you need an
    >>>>>>>> update panel aware one.
    >>>>>>>>
    >>>>>>>> -- bruce (sqlwork.com)
    >>>>>>>>
    >>>>>>>> Nathan Sokalski wrote:



    >>>>>>>>> On Sunday, December 06, 2009 8:11 PM Nathan Sokalski wrote:


    >>>>>>>>> I am using Visual Studio 2008 and ASP.NET 3.5, and my validator is one that
    >>>>>>>>> I wrote which inherits from BaseValidator (the validator was written using
    >>>>>>>>> Visual Studio 2008 and ASP.NET 3.5 as well). Any more suggestions or ideas?
    >>>>>>>>> Thanks.
    >>>>>>>>> --
    >>>>>>>>> Nathan Sokalski
    >>>>>>>>>
    >>>>>>>>> http://www.nathansokalski.com/



    >>>>>>>>>> On Monday, December 07, 2009 12:32 PM Gregory A. Beamer wrote:


    >>>>>>>>>> Video or text?
    >>>>>>>>>>
    >>>>>>>>>> There are quite a few links that talk about debugging AJAX on this
    >>>>>>>>>> Google search:
    >>>>>>>>>> http://snurl.com/tlfyg
    >>>>>>>>>>
    >>>>>>>>>> The top link is a You Tube video that shows how to do it.
    >>>>>>>>>>
    >>>>>>>>>> The search (above) is where I would start. if that yields nothing, then
    >>>>>>>>>> we can look at other options.
    >>>>>>>>>>
    >>>>>>>>>> Peace and Grace,
    >>>>>>>>>>
    >>>>>>>>>> --
    >>>>>>>>>> Gregory A. Beamer (MVP)
    >>>>>>>>>>
    >>>>>>>>>> Twitter: @gbworld
    >>>>>>>>>> Blog: http://gregorybeamer.spaces.live.com
    >>>>>>>>>>
    >>>>>>>>>> *******************************************
    >>>>>>>>>> | Think outside the box! |
    >>>>>>>>>> *******************************************



    >>>>>>>>>>> On Monday, December 07, 2009 2:49 PM Nathan Sokalski wrote:


    >>>>>>>>>>> Actually, I think I have found the source of the problem, as you will see in
    >>>>>>>>>>> the response from bruce barker (not that I did not appreciate yours or plan
    >>>>>>>>>>> on trying yours also). The problem is the script generated by BaseValidator
    >>>>>>>>>>> to set some of the expando attributes for the span tag which is the
    >>>>>>>>>>> validator (such as controltovalidate, errormessage, display,
    >>>>>>>>>>> validationGroup, etc.). The script works fine, but it needs rerun after the
    >>>>>>>>>>> UpdatePanel does one of it is asynch postbacks, which I am having trouble
    >>>>>>>>>>> figuring out how to do, since the script is generated and added completely
    >>>>>>>>>>> automatically. Any ideas (or if you think the problem could be something
    >>>>>>>>>>> else)? Thanks.
    >>>>>>>>>>> --
    >>>>>>>>>>> Nathan Sokalski
    >>>>>>>>>>>
    >>>>>>>>>>> http://www.nathansokalski.com/



    >>>>>>>>>>>> On Wednesday, December 09, 2009 10:26 AM Eric M wrote:


    >>>>>>>>>>>> I am having the exact same issue... That code is not being re-run on
    >>>>>>>>>>>> the asynch post-back, so when I access the property in client code, it
    >>>>>>>>>>>> is undefined.
    >>>>>>>>>>>>
    >>>>>>>>>>>> in
    >>>>>>>>>>>> n
    >>>>>>>>>>>> or
    >>>>>>>>>>>> he
    >>>>>>>>>>>> y
    >>>>>>>>>>>> ews:Xns9CDA753184E56gbworld@207.46.248.16...



    >>>>>>>>>>>>> On Wednesday, December 09, 2009 12:39 PM Nathan Sokalski wrote:


    >>>>>>>>>>>>> I found some stuff that says there are updated versions of the validators
    >>>>>>>>>>>>> for AJAX that fix this, but those posts were from 2007, and not only is this
    >>>>>>>>>>>>> over 2 years later, but I did my stuff with ASP.NET 3.5, and I always get
    >>>>>>>>>>>>> all the stuff from WindowsUpdate right away (it says the updates will be
    >>>>>>>>>>>>> provided through WindowsUpdate). Here is where I got that info:
    >>>>>>>>>>>>>
    >>>>>>>>>>>>> http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx
    >>>>>>>>>>>>>
    >>>>>>>>>>>>> I do not know if the article is wrong or if I do not have all the updates I
    >>>>>>>>>>>>> think I do, but maybe this will help us fix everything. Hopefully.
    >>>>>>>>>>>>> --
    >>>>>>>>>>>>> Nathan Sokalski
    >>>>>>>>>>>>>
    >>>>>>>>>>>>> http://www.nathansokalski.com/
    >>>>>>>>>>>>>
    >>>>>>>>>>>>> I am having the exact same issue... That code is not being re-run on
    >>>>>>>>>>>>> the asynch post-back, so when I access the property in client code, it
    >>>>>>>>>>>>> is undefined.



    >>>>>>>>>>>>> Submitted via EggHeadCafe - Software Developer Portal of Choice
    >>>>>>>>>>>>> Book Review: Excel 2010 - The Missing Manual [OReilly]
    >>>>>>>>>>>>> http://www.eggheadcafe.com/tutorial...w-excel-2010--the-missing-manual-oreilly.aspx
    Jay Woerndle, Sep 8, 2010
    #14
    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. Replies:
    3
    Views:
    463
    Rob Meade
    Aug 8, 2007
  2. Leon Mayne
    Replies:
    5
    Views:
    4,727
    Leon Mayne
    May 27, 2008
  3. SAL
    Replies:
    7
    Views:
    2,280
    Allen Chen [MSFT]
    Dec 18, 2008
  4. Nathan Sokalski
    Replies:
    1
    Views:
    564
    miher
    Jun 15, 2009
  5. Nathan Sokalski

    Validator not working when inside UpdatePanel

    Nathan Sokalski, Dec 4, 2009, in forum: ASP .Net Web Controls
    Replies:
    12
    Views:
    995
    Nathan Sokalski
    Dec 9, 2009
Loading...

Share This Page