Link to home
Create AccountLog in
Avatar of Karl Blackburn
Karl BlackburnFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Retrieve Hiddenfield Value after Javascript CHange

Hi,.

I am using Hiddenfields to push data from a webpage into the code behind, but have an issue as one field works and one doesn't.

The hiddenfields are

<asp:HiddenField ID="HiddenFieldballoona" runat="server" value="" />
<asp:HiddenField ID="HFballoonadesc" runat="server" value="" />

Open in new window


and the javascript is

function changeballoon(x,desc,rib)
{
document.getElementById('<%= HiddenFieldballoona.ClientID%>').value = "Balloon"+[x]+".png";
document.getElementById('<%= HFballoonadesc.ClientID%>').value = [desc];
}

Open in new window


and behind the scenes I am then using

HiddenFieldballoona.Value

Open in new window


It will quite happily pull the HFballoonadesc into the code behind after, but not HiddenFieldballoona - this will stay as whatever was loaded into it on page load.

Any ideas welcome?

Cheers
Karl
Avatar of Karl Blackburn
Karl Blackburn
Flag of United Kingdom of Great Britain and Northern Ireland image

ASKER

That parts work either way, I believe it was wrapped as originally I added text either side.

Its the

document.getElementById('<%= HiddenFieldballoona.ClientID%>').value = "Balloon"+[x]+".png";

That does exactly the same thing, but when I try to pull from it code behind will always default to the original value when the page was loaded.
Avatar of Gary
Are you sure values a,desc,rib are being passed to the function
If you change to text not hidden are the values inserted?
ASKER CERTIFIED SOLUTION
Avatar of Karl Blackburn
Karl Blackburn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
That does exactly the same thing, but when I try to pull from it code behind will always default to the original value when the page was loaded.

Just to clarify - once the page is rendered you can't access the ASP vars any more.

When you say "pull from the code behind" - where are you doing that?
Managed to find the answer