473,320 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Hidden Field value set in Javascript

Hello,

I am trying to set the value of a hidden field in Javacript in my
UserControl. I need to access the value in the code-behind.

For some reason, the value of the hidden field never gets set on the
client even though it is executing that function. Can anyone help me
figure out why? I am new to this, so please excuse if this seems
elementary.

I have my code snippets below.

Thank you in advance,
Fatima

>From my code-behind:
protected void SaveSelected(object blah)
{
// These values are always "Test" - the initial value of
hdnSelected
string test = hdnSelected.Value;
string test2 = blah.ToString();
}

>From my user control:

<asp:HiddenField ID="hdnSelected" runat="server" Value="Test" />

<script language="javascript" type="text/javascript">

var grid;
var SelectedIndexesPerPage = {};
var inputName;

function UpdateSelectedRows(pageIndex)
{
var selRows = grid.MasterTableView.SelectedRows;
var result = "";
if(typeof(selRows[0]) != "undefined")
{
result = selRows[0].ItemIndex.toString();
}
var i=1;
while(typeof(selRows[i]) != "undefined")
{
result = result + "," + selRows[i].ItemIndex.toString();
i=i+1;
}
SelectedIndexesPerPage[pageIndex] = result;

SaveHashValues();
var shidden = document.getElementById("<%=hdnSelected.ClientID
%>");
shidden.Value = result;
shidden.Value = "blah blah blah";
hdnSelected.Value = "nonononon";
// Testing saving in session variable
<% SaveSelected(hdnSelected.Value); %>
}

Feb 16 '07 #1
1 44257
the dom is case sensitive (and is always lowercase), its:

shidden.value = 'xxxx';

not sure the point of <% SaveSelected(hdnSelected.Value); %>, it should
be tied to page_load

-- bruce (sqlwork.com)

fa***********@gmail.com wrote:
Hello,

I am trying to set the value of a hidden field in Javacript in my
UserControl. I need to access the value in the code-behind.

For some reason, the value of the hidden field never gets set on the
client even though it is executing that function. Can anyone help me
figure out why? I am new to this, so please excuse if this seems
elementary.

I have my code snippets below.

Thank you in advance,
Fatima

>>From my code-behind:

protected void SaveSelected(object blah)
{
// These values are always "Test" - the initial value of
hdnSelected
string test = hdnSelected.Value;
string test2 = blah.ToString();
}

>>From my user control:


<asp:HiddenField ID="hdnSelected" runat="server" Value="Test" />

<script language="javascript" type="text/javascript">

var grid;
var SelectedIndexesPerPage = {};
var inputName;

function UpdateSelectedRows(pageIndex)
{
var selRows = grid.MasterTableView.SelectedRows;
var result = "";
if(typeof(selRows[0]) != "undefined")
{
result = selRows[0].ItemIndex.toString();
}
var i=1;
while(typeof(selRows[i]) != "undefined")
{
result = result + "," + selRows[i].ItemIndex.toString();
i=i+1;
}
SelectedIndexesPerPage[pageIndex] = result;

SaveHashValues();
var shidden = document.getElementById("<%=hdnSelected.ClientID
%>");
shidden.Value = result;
shidden.Value = "blah blah blah";
hdnSelected.Value = "nonononon";
// Testing saving in session variable
<% SaveSelected(hdnSelected.Value); %>
}
Feb 17 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Rauf ul Hassan | last post by:
I submit a form with a submit button and method of form is Post. When I use request.getParameter() in the next page to get the value of a hidden field, I get a NULL value. However when I use Get...
2
by: Patrick | last post by:
I currently us JavaScript to populate a hidden field with my scroll location in order to retain the page location when I post the page back to itself. However, I don't know how to pass that hidden...
1
by: Jim | last post by:
I have a 2 checkboxes and a hidden field..what I want to happen is that you can only click on 1 of these checkboxes at a time and when you check a checkbox it will assign the hidden field...
2
by: Rodusa | last post by:
I have a hidden field inside one datagrid which I can't get to make it keep its state after a postback event. Look field: <input type="hidden" id="TxtHiddenItem_id" name="TxtHiddenItem_id"...
4
by: PJ6 | last post by:
From a control's onkeypress the below javascript snippet is executed. I am attmpting to set the value of a hidden field... I believe I'd be able to get the contents of the hidden field by using...
1
by: Anne Marie | last post by:
I am updating a hidden fields' value client side in javascript. The assigned value seems to be correct from the alert message but when I postback the page to server side the value assigned to the...
2
by: pschwede | last post by:
We are using a WYSIWYG (fckeditor) and trying to implement a third-party spellchecker (WinterTree). We have everything almost working. When the spellcheck is run, it does not post suggested words...
14
Frinavale
by: Frinavale | last post by:
I've been trying to test my web application using Internet Explorer 8 (release candidate 1) and have been experiencing some major problems. I'm hoping you can help me with this one. I have a...
16
by: kirankumarn | last post by:
I want to read xml which is stored in hidden field using javascript
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.