How to delete a hidden input's value in code-behind

A

Alex

Is there any way to delete the value of a html hidden input field from code-behind? I use an html hidden input to store an array of data. I collect this data using Request.Form or Request.Params. After I use it, I want to force the deletion of it, so a user cannot hit their refresh button on their browser and trigger the same events that just occurred.

I have tried using Request.Params.Remove("HiddenField"), Request.Form.Remove("HiddenField"), Request.Form.Clear(), ect, but all are read-only. I have tried using RegisterHiddenField("HiddenField","") but this is not killing the HiddenField's value. Is it possible to delete this client side control from the server? Are there any crafty javascript commands I am overlooking to accomplish this?

Thanks,

Alex
 
E

Eliyahu Goldin

Alex,

The refresh button will always repeat previous postback exactly as it was no matter how you modify the page. That is built-in behavior of the browser and you can't change it. You can fight it on server side by implementing a sort of algorithm for detecting repeating postbacks.

Eliyahu

Is there any way to delete the value of a html hidden input field from code-behind? I use an html hidden input to store an array of data. I collect this data using Request.Form or Request.Params. After I use it, I want to force the deletion of it, so a user cannot hit their refresh button on their browser and trigger the same events that just occurred.

I have tried using Request.Params.Remove("HiddenField"), Request.Form.Remove("HiddenField"), Request.Form.Clear(), ect, but all are read-only. I have tried using RegisterHiddenField("HiddenField","") but this is not killing the HiddenField's value. Is it possible to delete this client side control from the server? Are there any crafty javascript commands I am overlooking to accomplish this?

Thanks,

Alex
 
A

Alex

Thanks. Now how can I detect repeating post backs?

Alex
Alex,

The refresh button will always repeat previous postback exactly as it was no matter how you modify the page. That is built-in behavior of the browser and you can't change it. You can fight it on server side by implementing a sort of algorithm for detecting repeating postbacks.

Eliyahu

Is there any way to delete the value of a html hidden input field from code-behind? I use an html hidden input to store an array of data. I collect this data using Request.Form or Request.Params. After I use it, I want to force the deletion of it, so a user cannot hit their refresh button on their browser and trigger the same events that just occurred.

I have tried using Request.Params.Remove("HiddenField"), Request.Form.Remove("HiddenField"), Request.Form.Clear(), ect, but all are read-only. I have tried using RegisterHiddenField("HiddenField","") but this is not killing the HiddenField's value. Is it possible to delete this client side control from the server? Are there any crafty javascript commands I am overlooking to accomplish this?

Thanks,

Alex
 
E

Eliyahu Goldin

Use something unique, that can't be posted back again, and save it on server side. If it comes again, that must be from the refresh button. You can use a timestamp if you don't have anything else unique on the page.

Eliyahu

Thanks. Now how can I detect repeating post backs?

Alex
Alex,

The refresh button will always repeat previous postback exactly as it was no matter how you modify the page. That is built-in behavior of the browser and you can't change it. You can fight it on server side by implementing a sort of algorithm for detecting repeating postbacks.

Eliyahu

Is there any way to delete the value of a html hidden input field from code-behind? I use an html hidden input to store an array of data. I collect this data using Request.Form or Request.Params. After I use it, I want to force the deletion of it, so a user cannot hit their refresh button on their browser and trigger the same events that just occurred.

I have tried using Request.Params.Remove("HiddenField"), Request.Form.Remove("HiddenField"), Request.Form.Clear(), ect, but all are read-only. I have tried using RegisterHiddenField("HiddenField","") but this is not killing the HiddenField's value. Is it possible to delete this client side control from the server? Are there any crafty javascript commands I am overlooking to accomplish this?

Thanks,

Alex
 
A

Alex

Eliyahu,

Thanks for the help. This will work for me. Here's what I have implemented.

In my function which uses the hidden input's value, I create a session variable. On my page load, I test this session variable to be null, or something. Since I only want to make changes if the hidden input's value is different than the last time I changed, I can perform my logic here. On a refresh, the session variable will be the same as the hidden input value, so I can disregard it.

Problem solved, thanks!

Alex
Use something unique, that can't be posted back again, and save it on server side. If it comes again, that must be from the refresh button. You can use a timestamp if you don't have anything else unique on the page.

Eliyahu

Thanks. Now how can I detect repeating post backs?

Alex
Alex,

The refresh button will always repeat previous postback exactly as it was no matter how you modify the page. That is built-in behavior of the browser and you can't change it. You can fight it on server side by implementing a sort of algorithm for detecting repeating postbacks.

Eliyahu

Is there any way to delete the value of a html hidden input field from code-behind? I use an html hidden input to store an array of data. I collect this data using Request.Form or Request.Params. After I use it, I want to force the deletion of it, so a user cannot hit their refresh button on their browser and trigger the same events that just occurred.

I have tried using Request.Params.Remove("HiddenField"), Request.Form.Remove("HiddenField"), Request.Form.Clear(), ect, but all are read-only. I have tried using RegisterHiddenField("HiddenField","") but this is not killing the HiddenField's value. Is it possible to delete this client side control from the server? Are there any crafty javascript commands I am overlooking to accomplish this?

Thanks,

Alex
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top