Professional Web Applications Themes

Avoid adding a new record on refreshing the browser - ASP.NET Data Grid Control

Hi, I'm working with datagrid. And users can add "Remarks" by clicking the [Add] link button in the footer template. It's working fine like when the user enter the remarks and click on [Add], the remarks are getting added. But if we refresh the page, a new record is getting added, which should not happen I do not have any unique columns (other than Remark Id) in the table sine we can add the remarks any number of times. Any suggestion in this regards is highly appreciated. srinivas...

  1. #1

    Default Avoid adding a new record on refreshing the browser

    Hi,

    I'm working with datagrid. And users can add "Remarks" by clicking the [Add]
    link button in the footer template.

    It's working fine like when the user enter the remarks and click on [Add],
    the remarks are getting added.

    But if we refresh the page, a new record is getting added, which should not
    happen

    I do not have any unique columns (other than Remark Id) in the table sine we
    can add the remarks any number of times.

    Any suggestion in this regards is highly appreciated.

    srinivas
    srinivas Guest

  2. #2

    Default Re: Avoid adding a new record on refreshing the browser

    That's built-in behavior of Refresh button. It always repeats the last
    postback. You can't change it. You can protect against it on server side if
    you include something like a timestamp in the postback. Then you can compare
    the timestamp from the new postback with the one from the previous postback.
    If they match, you got Refresh click.

    Eliyahu

    "srinivas" <srinivasdiscussions.microsoft.com> wrote in message
    news:8BC23FFA-7375-4A76-A157-A05DE737D1EBmicrosoft.com...
    > Hi,
    >
    > I'm working with datagrid. And users can add "Remarks" by clicking the
    [Add]
    > link button in the footer template.
    >
    > It's working fine like when the user enter the remarks and click on [Add],
    > the remarks are getting added.
    >
    > But if we refresh the page, a new record is getting added, which should
    not
    > happen
    >
    > I do not have any unique columns (other than Remark Id) in the table sine
    we
    > can add the remarks any number of times.
    >
    > Any suggestion in this regards is highly appreciated.
    >
    > srinivas

    Eliyahu Goldin Guest

  3. #3

    Default Re: Avoid adding a new record on refreshing the browser

    Iīm not sure aboute this, but canīt you use if(!Page.IsPostback) ?

    /Marre

    "Eliyahu Goldin" <removemeegoldinmonarchmed.com> wrote in message
    news:euxQ2ckIFHA.2728TK2MSFTNGP09.phx.gbl...
    > That's built-in behavior of Refresh button. It always repeats the last
    > postback. You can't change it. You can protect against it on server side
    > if
    > you include something like a timestamp in the postback. Then you can
    > compare
    > the timestamp from the new postback with the one from the previous
    > postback.
    > If they match, you got Refresh click.
    >
    > Eliyahu
    >
    > "srinivas" <srinivasdiscussions.microsoft.com> wrote in message
    > news:8BC23FFA-7375-4A76-A157-A05DE737D1EBmicrosoft.com...
    >> Hi,
    >>
    >> I'm working with datagrid. And users can add "Remarks" by clicking the
    > [Add]
    >> link button in the footer template.
    >>
    >> It's working fine like when the user enter the remarks and click on
    >> [Add],
    >> the remarks are getting added.
    >>
    >> But if we refresh the page, a new record is getting added, which should
    > not
    >> happen
    >>
    >> I do not have any unique columns (other than Remark Id) in the table sine
    > we
    >> can add the remarks any number of times.
    >>
    >> Any suggestion in this regards is highly appreciated.
    >>
    >> srinivas
    >
    >

    MA Guest

  4. #4

    Default Re: Avoid adding a new record on refreshing the browser

    Marre,

    Page.IsPostback will always return true after pressing Refresh for the
    simple reason it IS a postback.

    Eliyahu

    "MA" <news.removethis.supremelink.se> wrote in message
    news:392ih0F5smo05U1individual.net...
    > Iīm not sure aboute this, but canīt you use if(!Page.IsPostback) ?
    >
    > /Marre
    >
    > "Eliyahu Goldin" <removemeegoldinmonarchmed.com> wrote in message
    > news:euxQ2ckIFHA.2728TK2MSFTNGP09.phx.gbl...
    > > That's built-in behavior of Refresh button. It always repeats the last
    > > postback. You can't change it. You can protect against it on server side
    > > if
    > > you include something like a timestamp in the postback. Then you can
    > > compare
    > > the timestamp from the new postback with the one from the previous
    > > postback.
    > > If they match, you got Refresh click.
    > >
    > > Eliyahu
    > >
    > > "srinivas" <srinivasdiscussions.microsoft.com> wrote in message
    > > news:8BC23FFA-7375-4A76-A157-A05DE737D1EBmicrosoft.com...
    > >> Hi,
    > >>
    > >> I'm working with datagrid. And users can add "Remarks" by clicking the
    > > [Add]
    > >> link button in the footer template.
    > >>
    > >> It's working fine like when the user enter the remarks and click on
    > >> [Add],
    > >> the remarks are getting added.
    > >>
    > >> But if we refresh the page, a new record is getting added, which should
    > > not
    > >> happen
    > >>
    > >> I do not have any unique columns (other than Remark Id) in the table
    sine
    > > we
    > >> can add the remarks any number of times.
    > >>
    > >> Any suggestion in this regards is highly appreciated.
    > >>
    > >> srinivas
    > >
    > >
    >
    >

    Eliyahu Goldin Guest

  5. #5

    Default Re: Avoid adding a new record on refreshing the browser

    Hi Eliyahu!

    Yes it will. Thats why i used !Page.IsPostback. Shouldīnt that solve the
    problem with F5?

    F5 is allways a postback. If you use:
    if(!Page.IsPostback)
    {
    code.....
    }
    the code inside my if-block would not be used when F5 is pressed.

    Is something I miss here, or could this work? :)

    /Marre

    "Eliyahu Goldin" <removemeegoldinmonarchmed.com> wrote in message
    news:OrwI2rvIFHA.3628TK2MSFTNGP15.phx.gbl...
    > Marre,
    >
    > Page.IsPostback will always return true after pressing Refresh for the
    > simple reason it IS a postback.
    >
    > Eliyahu
    >
    > "MA" <news.removethis.supremelink.se> wrote in message
    > news:392ih0F5smo05U1individual.net...
    >> Iīm not sure aboute this, but canīt you use if(!Page.IsPostback) ?
    >>
    >> /Marre
    >>
    >> "Eliyahu Goldin" <removemeegoldinmonarchmed.com> wrote in message
    >> news:euxQ2ckIFHA.2728TK2MSFTNGP09.phx.gbl...
    >> > That's built-in behavior of Refresh button. It always repeats the last
    >> > postback. You can't change it. You can protect against it on server
    >> > side
    >> > if
    >> > you include something like a timestamp in the postback. Then you can
    >> > compare
    >> > the timestamp from the new postback with the one from the previous
    >> > postback.
    >> > If they match, you got Refresh click.
    >> >
    >> > Eliyahu
    >> >
    >> > "srinivas" <srinivasdiscussions.microsoft.com> wrote in message
    >> > news:8BC23FFA-7375-4A76-A157-A05DE737D1EBmicrosoft.com...
    >> >> Hi,
    >> >>
    >> >> I'm working with datagrid. And users can add "Remarks" by clicking the
    >> > [Add]
    >> >> link button in the footer template.
    >> >>
    >> >> It's working fine like when the user enter the remarks and click on
    >> >> [Add],
    >> >> the remarks are getting added.
    >> >>
    >> >> But if we refresh the page, a new record is getting added, which
    >> >> should
    >> > not
    >> >> happen
    >> >>
    >> >> I do not have any unique columns (other than Remark Id) in the table
    > sine
    >> > we
    >> >> can add the remarks any number of times.
    >> >>
    >> >> Any suggestion in this regards is highly appreciated.
    >> >>
    >> >> srinivas
    >> >
    >> >
    >>
    >>
    >
    >

    MA Guest

  6. #6

    Default Re: Avoid adding a new record on refreshing the browser

    Marre,

    The question is how you differentiate between a real postback caused, for
    example, by a form button click, and a postback caused by F5. If you use
    if(!Page.IsPostback), you are going to miss all your real postbacks.

    What you are suggesting is good in a case when you don't have any real
    postbacks, for example you are producing a view-only form.

    Eliyahu

    "MA" <news.removethis.supremelink.se> wrote in message
    news:392oqqF5u0cvbU1individual.net...
    > Hi Eliyahu!
    >
    > Yes it will. Thats why i used !Page.IsPostback. Shouldīnt that solve the
    > problem with F5?
    >
    > F5 is allways a postback. If you use:
    > if(!Page.IsPostback)
    > {
    > code.....
    > }
    > the code inside my if-block would not be used when F5 is pressed.
    >
    > Is something I miss here, or could this work? :)
    >
    > /Marre
    >
    > "Eliyahu Goldin" <removemeegoldinmonarchmed.com> wrote in message
    > news:OrwI2rvIFHA.3628TK2MSFTNGP15.phx.gbl...
    > > Marre,
    > >
    > > Page.IsPostback will always return true after pressing Refresh for the
    > > simple reason it IS a postback.
    > >
    > > Eliyahu
    > >
    > > "MA" <news.removethis.supremelink.se> wrote in message
    > > news:392ih0F5smo05U1individual.net...
    > >> Iīm not sure aboute this, but canīt you use if(!Page.IsPostback) ?
    > >>
    > >> /Marre
    > >>
    > >> "Eliyahu Goldin" <removemeegoldinmonarchmed.com> wrote in message
    > >> news:euxQ2ckIFHA.2728TK2MSFTNGP09.phx.gbl...
    > >> > That's built-in behavior of Refresh button. It always repeats the
    last
    > >> > postback. You can't change it. You can protect against it on server
    > >> > side
    > >> > if
    > >> > you include something like a timestamp in the postback. Then you can
    > >> > compare
    > >> > the timestamp from the new postback with the one from the previous
    > >> > postback.
    > >> > If they match, you got Refresh click.
    > >> >
    > >> > Eliyahu
    > >> >
    > >> > "srinivas" <srinivasdiscussions.microsoft.com> wrote in message
    > >> > news:8BC23FFA-7375-4A76-A157-A05DE737D1EBmicrosoft.com...
    > >> >> Hi,
    > >> >>
    > >> >> I'm working with datagrid. And users can add "Remarks" by clicking
    the
    > >> > [Add]
    > >> >> link button in the footer template.
    > >> >>
    > >> >> It's working fine like when the user enter the remarks and click on
    > >> >> [Add],
    > >> >> the remarks are getting added.
    > >> >>
    > >> >> But if we refresh the page, a new record is getting added, which
    > >> >> should
    > >> > not
    > >> >> happen
    > >> >>
    > >> >> I do not have any unique columns (other than Remark Id) in the table
    > > sine
    > >> > we
    > >> >> can add the remarks any number of times.
    > >> >>
    > >> >> Any suggestion in this regards is highly appreciated.
    > >> >>
    > >> >> srinivas
    > >> >
    > >> >
    > >>
    > >>
    > >
    > >
    >
    >

    Eliyahu Goldin Guest

  7. #7

    Default Re: Avoid adding a new record on refreshing the browser

    Check this out...

    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/BedrockASPNET.asp[/url]


    Ric Bernat Guest

Similar Threads

  1. Replies: 0
    Last Post: March 19th, 07:39 AM
  2. After refreshing browser .as file loss updated value
    By Nagendra2008 in forum Macromedia Flex General Discussion
    Replies: 3
    Last Post: May 7th, 07:31 PM
  3. Stop adding record in subform after record count = 1
    By Charlie in forum Microsoft Access
    Replies: 0
    Last Post: July 31st, 10:42 AM
  4. Adding a new record when the record source is a query.
    By Andy in forum Microsoft Access
    Replies: 0
    Last Post: July 29th, 01:41 PM
  5. Adding record to MDB
    By Leif Hauge in forum ASP Database
    Replies: 2
    Last Post: July 7th, 10:41 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139