Home All Groups Group Topic Archive Search About

Avoid adding a new record on refreshing the browser

Author
4 Mar 2005 1:59 AM
srinivas
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

Author
6 Mar 2005 12:26 PM
Eliyahu Goldin
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
Author
7 Mar 2005 8:42 AM
MA
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
>
>
Author
7 Mar 2005 9:53 AM
Eliyahu Goldin
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
> >
> >
>
>
Author
7 Mar 2005 10:30 AM
MA
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
>> >
>> >
>>
>>
>
>
Author
7 Mar 2005 12:20 PM
Eliyahu Goldin
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
> >> >
> >> >
> >>
> >>
> >
> >
>
>