|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Avoid adding a new record on refreshing the browserHi,
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 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 Show quoteHide quote "srinivas" <srini***@discussions.microsoft.com> wrote in message news:8BC23FFA-7375-4A76-A157-A05DE737D1EB@microsoft.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 I´m not sure aboute this, but can´t you use if(!Page.IsPostback) ?
/Marre Show quoteHide quote "Eliyahu Goldin" <removemeegol***@monarchmed.com> wrote in message news:euxQ2ckIFHA.2728@TK2MSFTNGP09.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" <srini***@discussions.microsoft.com> wrote in message > news:8BC23FFA-7375-4A76-A157-A05DE737D1EB@microsoft.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 > > Marre,
Page.IsPostback will always return true after pressing Refresh for the simple reason it IS a postback. Eliyahu Show quoteHide quote "MA" <n***@.removethis.supremelink.se> wrote in message news:392ih0F5smo05U1@individual.net... > I´m not sure aboute this, but can´t you use if(!Page.IsPostback) ? > > /Marre > > "Eliyahu Goldin" <removemeegol***@monarchmed.com> wrote in message > news:euxQ2ckIFHA.2728@TK2MSFTNGP09.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" <srini***@discussions.microsoft.com> wrote in message > > news:8BC23FFA-7375-4A76-A157-A05DE737D1EB@microsoft.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 > > > > > > 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 Show quoteHide quote "Eliyahu Goldin" <removemeegol***@monarchmed.com> wrote in message news:OrwI2rvIFHA.3628@TK2MSFTNGP15.phx.gbl... > Marre, > > Page.IsPostback will always return true after pressing Refresh for the > simple reason it IS a postback. > > Eliyahu > > "MA" <n***@.removethis.supremelink.se> wrote in message > news:392ih0F5smo05U1@individual.net... >> I´m not sure aboute this, but can´t you use if(!Page.IsPostback) ? >> >> /Marre >> >> "Eliyahu Goldin" <removemeegol***@monarchmed.com> wrote in message >> news:euxQ2ckIFHA.2728@TK2MSFTNGP09.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" <srini***@discussions.microsoft.com> wrote in message >> > news:8BC23FFA-7375-4A76-A157-A05DE737D1EB@microsoft.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 >> > >> > >> >> > > 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 Show quoteHide quote "MA" <n***@.removethis.supremelink.se> wrote in message news:392oqqF5u0cvbU1@individual.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" <removemeegol***@monarchmed.com> wrote in message > news:OrwI2rvIFHA.3628@TK2MSFTNGP15.phx.gbl... > > Marre, > > > > Page.IsPostback will always return true after pressing Refresh for the > > simple reason it IS a postback. > > > > Eliyahu > > > > "MA" <n***@.removethis.supremelink.se> wrote in message > > news:392ih0F5smo05U1@individual.net... > >> I´m not sure aboute this, but can´t you use if(!Page.IsPostback) ? > >> > >> /Marre > >> > >> "Eliyahu Goldin" <removemeegol***@monarchmed.com> wrote in message > >> news:euxQ2ckIFHA.2728@TK2MSFTNGP09.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" <srini***@discussions.microsoft.com> wrote in message > >> > news:8BC23FFA-7375-4A76-A157-A05DE737D1EB@microsoft.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 > >> > > >> > > >> > >> > > > > > > |
|||||||||||||||||||||||