error reposting data

Discussion in 'ASP .Net' started by Leon, Feb 11, 2010.

  1. Leon

    Leon Guest

    Hi everybody.

    I am adding image buttons to my web form programmatically and adding
    onclientclick for each button to call java function to save some info. When
    form is reposted I get an error message:

    An error has occurred because a control with id
    'ctl00$ContentPlaceHolder1$ctl01' could not be located or a different control
    is assigned to the same ID after postback. If the ID is not assigned,
    explicitly set the ID property of controls that raise postback events to
    avoid this error.

    Probably I get this message, because on repost I do not recreate those image
    buttons and I do not need to recreate them, because I need to show just a big
    picture of the product.

    How can I avoid this problem?
     
    Leon, Feb 11, 2010
    #1
    1. Advertising

  2. On Feb 11, 8:31 pm, Leon <> wrote:
    > Hi everybody.
    >
    > I am adding image buttons to my web form programmatically and adding
    > onclientclick for each button to call java function to save some info. When
    > form is reposted I get an error message:
    >
    > An error has occurred because a control with id
    > 'ctl00$ContentPlaceHolder1$ctl01' could not be located or a different control
    > is assigned to the same ID after postback. If the ID is not assigned,
    > explicitly set the ID property of controls that raise postback events to
    > avoid this error.
    >
    > Probably I get this message, because on repost I do not recreate those image
    > buttons and I do not need to recreate them, because I need to show just a big
    > picture of the product.
    >
    > How can I avoid this problem?


    Did you add unique id to each control when you create it from the code?
     
    Alexey Smirnov, Feb 12, 2010
    #2
    1. Advertising

  3. Leon

    If it's a javascript call that's being made from the button and there is no
    need to post back to the server then you could correct this error by
    stopping the post-back altogether by adding: "return false;" to your
    javascript called from the button.

    However if someone has javascript turned off then the postback will still
    occur and if you don't recreated the dynamic controls in .net you will
    always get the error.

    --


    Sincerely,

    S. Justin Gengo, MCP

    Free code library at:
    http://www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche

    "Leon" <> wrote in message
    news:...
    > Hi everybody.
    >
    > I am adding image buttons to my web form programmatically and adding
    > onclientclick for each button to call java function to save some info.
    > When
    > form is reposted I get an error message:
    >
    > An error has occurred because a control with id
    > 'ctl00$ContentPlaceHolder1$ctl01' could not be located or a different
    > control
    > is assigned to the same ID after postback. If the ID is not assigned,
    > explicitly set the ID property of controls that raise postback events to
    > avoid this error.
    >
    > Probably I get this message, because on repost I do not recreate those
    > image
    > buttons and I do not need to recreate them, because I need to show just a
    > big
    > picture of the product.
    >
    > How can I avoid this problem?
     
    S. Justin Gengo, Feb 12, 2010
    #3
  4. Leon

    Leon Guest

    No. I did not. Would it help if I did?

    "Alexey Smirnov" wrote:

    > On Feb 11, 8:31 pm, Leon <> wrote:
    > > Hi everybody.
    > >
    > > I am adding image buttons to my web form programmatically and adding
    > > onclientclick for each button to call java function to save some info. When
    > > form is reposted I get an error message:
    > >
    > > An error has occurred because a control with id
    > > 'ctl00$ContentPlaceHolder1$ctl01' could not be located or a different control
    > > is assigned to the same ID after postback. If the ID is not assigned,
    > > explicitly set the ID property of controls that raise postback events to
    > > avoid this error.
    > >
    > > Probably I get this message, because on repost I do not recreate those image
    > > buttons and I do not need to recreate them, because I need to show just a big
    > > picture of the product.
    > >
    > > How can I avoid this problem?

    >
    > Did you add unique id to each control when you create it from the code?
    > .
    >
     
    Leon, Feb 12, 2010
    #4
  5. Leon

    Leon Guest

    I do need to postback. I need to show a large picture of selected product. Is
    there any other way to do the same thing?

    "S. Justin Gengo" wrote:

    > Leon
    >
    > If it's a javascript call that's being made from the button and there is no
    > need to post back to the server then you could correct this error by
    > stopping the post-back altogether by adding: "return false;" to your
    > javascript called from the button.
    >
    > However if someone has javascript turned off then the postback will still
    > occur and if you don't recreated the dynamic controls in .net you will
    > always get the error.
    >
    > --
    >
    >
    > Sincerely,
    >
    > S. Justin Gengo, MCP
    >
    > Free code library at:
    > http://www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzsche
    >
    > "Leon" <> wrote in message
    > news:...
    > > Hi everybody.
    > >
    > > I am adding image buttons to my web form programmatically and adding
    > > onclientclick for each button to call java function to save some info.
    > > When
    > > form is reposted I get an error message:
    > >
    > > An error has occurred because a control with id
    > > 'ctl00$ContentPlaceHolder1$ctl01' could not be located or a different
    > > control
    > > is assigned to the same ID after postback. If the ID is not assigned,
    > > explicitly set the ID property of controls that raise postback events to
    > > avoid this error.
    > >
    > > Probably I get this message, because on repost I do not recreate those
    > > image
    > > buttons and I do not need to recreate them, because I need to show just a
    > > big
    > > picture of the product.
    > >
    > > How can I avoid this problem?

    >
    > .
    >
     
    Leon, Feb 12, 2010
    #5
  6. Leon

    Leon Guest

    Alexey.

    I tried your suggestion and it worked.
    Thanks a lot.



    "Alexey Smirnov" wrote:

    > On Feb 11, 8:31 pm, Leon <> wrote:
    > > Hi everybody.
    > >
    > > I am adding image buttons to my web form programmatically and adding
    > > onclientclick for each button to call java function to save some info. When
    > > form is reposted I get an error message:
    > >
    > > An error has occurred because a control with id
    > > 'ctl00$ContentPlaceHolder1$ctl01' could not be located or a different control
    > > is assigned to the same ID after postback. If the ID is not assigned,
    > > explicitly set the ID property of controls that raise postback events to
    > > avoid this error.
    > >
    > > Probably I get this message, because on repost I do not recreate those image
    > > buttons and I do not need to recreate them, because I need to show just a big
    > > picture of the product.
    > >
    > > How can I avoid this problem?

    >
    > Did you add unique id to each control when you create it from the code?
    > .
    >
     
    Leon, Feb 12, 2010
    #6
  7. Leon,

    If you need to re-post dot net wants to automatically check the values of
    the controls posted back. So you'll need to re-create the dynamic controls
    each time. That's what dot net would do if the controls were added to the
    page normally so you aren't creating more work than normal. You're just
    re-creating them on your own rather than using the framework to do so.


    --


    Sincerely,

    S. Justin Gengo, MCP

    Free code library at:
    http://www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche

    "Leon" <> wrote in message
    news:...
    > I do need to postback. I need to show a large picture of selected product.
    > Is
    > there any other way to do the same thing?
    >
    > "S. Justin Gengo" wrote:
    >
    >> Leon
    >>
    >> If it's a javascript call that's being made from the button and there is
    >> no
    >> need to post back to the server then you could correct this error by
    >> stopping the post-back altogether by adding: "return false;" to your
    >> javascript called from the button.
    >>
    >> However if someone has javascript turned off then the postback will still
    >> occur and if you don't recreated the dynamic controls in .net you will
    >> always get the error.
    >>
    >> --
    >>
    >>
    >> Sincerely,
    >>
    >> S. Justin Gengo, MCP
    >>
    >> Free code library at:
    >> http://www.aboutfortunate.com
    >>
    >> "Out of chaos comes order."
    >> Nietzsche
    >>
    >> "Leon" <> wrote in message
    >> news:...
    >> > Hi everybody.
    >> >
    >> > I am adding image buttons to my web form programmatically and adding
    >> > onclientclick for each button to call java function to save some info.
    >> > When
    >> > form is reposted I get an error message:
    >> >
    >> > An error has occurred because a control with id
    >> > 'ctl00$ContentPlaceHolder1$ctl01' could not be located or a different
    >> > control
    >> > is assigned to the same ID after postback. If the ID is not assigned,
    >> > explicitly set the ID property of controls that raise postback events
    >> > to
    >> > avoid this error.
    >> >
    >> > Probably I get this message, because on repost I do not recreate those
    >> > image
    >> > buttons and I do not need to recreate them, because I need to show just
    >> > a
    >> > big
    >> > picture of the product.
    >> >
    >> > How can I avoid this problem?

    >>
    >> .
    >>
     
    S. Justin Gengo, Feb 14, 2010
    #7
  8. On Feb 12, 7:33 pm, Leon <> wrote:
    > No. I did not. Would it help if I did?
    >
    >
    >
    > "Alexey Smirnov" wrote:
    > > On Feb 11, 8:31 pm, Leon <> wrote:
    > > > Hi everybody.

    >
    > > > I am adding image buttons to my web form programmatically and adding
    > > > onclientclick for each button to call java function to save some info.. When
    > > > form is reposted I get an error message:

    >
    > > > An error has occurred because a control with id
    > > > 'ctl00$ContentPlaceHolder1$ctl01' could not be located or a different control
    > > > is assigned to the same ID after postback. If the ID is not assigned,
    > > > explicitly set the ID property of controls that raise postback events to
    > > > avoid this error.

    >
    > > > Probably I get this message, because on repost I do not recreate those image
    > > > buttons and I do not need to recreate them, because I need to show just a big
    > > > picture of the product.

    >
    > > > How can I avoid this problem?

    >
    > > Did you add unique id to each control when you create it from the code?
    > > .- Hide quoted text -

    >
    > - Show quoted text -


    Yes, it helped as you can see. It was also mentioned in the error
    message you got: "If the ID is not assigned, explicitly set the ID
    property of controls that raise postback events to avoid this error".
    Glad, that it helps,

    Cheers!
     
    Alexey Smirnov, Feb 14, 2010
    #8
    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. Ersin Gençtürk

    RePosting window.opener windows to server.

    Ersin Gençtürk, Jul 3, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    368
    Ersin Gençtürk
    Jul 3, 2003
  2. Netsharp Ninja
    Replies:
    0
    Views:
    359
    Netsharp Ninja
    Apr 5, 2004
  3. =?Utf-8?B?Sm9obg==?=

    reposting causes flickering

    =?Utf-8?B?Sm9obg==?=, Sep 17, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    323
    =?Utf-8?B?Sm9obg==?=
    Sep 17, 2004
  4. =?Utf-8?B?UnVkeQ==?=
    Replies:
    0
    Views:
    327
    =?Utf-8?B?UnVkeQ==?=
    May 11, 2005
  5. Administrator

    reposting form data

    Administrator, Dec 30, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    305
    comphilip
    Jan 4, 2009
Loading...

Share This Page