Hye,
Is it possible to change/reset hiddenfield value to empty string from code behind?
I've tried methods below but none works;
1) hdnKey.Value = ""
2) Dim hdn As HiddenField = DirectCast(FindControl("hdnKey"), HiddenField)
hdn.Value = ""
Thanks.
---- UPDATE 1----
This is aspx codes:
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:HiddenField ID="hdnKey" runat="server" />
<%-- Other controls here --%>
</ContentTemplate>
</asp:UpdatePanel>
* Even if i move the hiddenfield outside the update panel, it still didnt work.
--- UPDATE 2 ----
I assign value to hiddenfield using javascript.
After that, I want to reset back the value to empty string.
<script>
document.onkeydown = KeyDownHandler;
document.onkeyup = KeyUpHandler;
var CTRL = false;
var SHIFT = false;
var ALT = false;
var CHAR_CODE = -1;
var confirm_value = document.createElement("INPUT");
var hdnKey = document.getElementById('<%= hdnKey.ClientID %>');
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
var a = hdnKey.value;
function KeyDownHandler(e) {
var x = '';
if (document.all) {
var evnt = window.event;
x = evnt.keyCode;
}
else {
x = e.keyCode;
}
DetectKeys(x, true);
}
function KeyUpHandler(e) {
var x = '';
if (document.all) {
var evnt = window.event;
x = evnt.keyCode;
}
else {
x = e.keyCode;
}
DetectKeys(x, false);
}
function DetectKeys(KeyCode, IsKeyDown) {
if (KeyCode == '16') {
SHIFT = IsKeyDown;
confirm_value.value = "16";
}
else if (KeyCode == '17') {
CTRL = IsKeyDown;
confirm_value.value = "17";
}
else if (KeyCode == '18') {
ALT = IsKeyDown;
confirm_value.value = "";
}
else {
confirm_value.value = "";
}
document.forms[0].appendChild(confirm_value);
document.forms[0].appendChild(hdnKey);
hdnKey.value = confirm_value.value;
}
</script>