473,322 Members | 1,347 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,322 software developers and data experts.

HiddenField

Hello All,

I am trying to make use the HiddenField server control to make a
server-side variable visible to a client script.
I set the value of the HiddenField inside of the Page_Load event.

protected void Page_Load(object sender, EventArgs e)
{
this.myHiddenField.Value = myVar;
}

I am able to access this value in my client script.
If a PostBack occurs, myHiddenField.Value is updated server-side, but
the value client-side always remains the same - the initial value when
the page first loads...

I'm missing something...pointers appreciated..

Thanks in advance

Jul 16 '07 #1
5 2380
What do you mean when you say the value is updated server side? Have you
stepped through with the debugger to be sure? Have you viewed the output
source to make sure the hidden field value is not updated on the client
side?

I tried a simple example based on your scenario, and the values are updated
as expected.
"hharry" <pa*********@nyc.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
Hello All,

I am trying to make use the HiddenField server control to make a
server-side variable visible to a client script.
I set the value of the HiddenField inside of the Page_Load event.

protected void Page_Load(object sender, EventArgs e)
{
this.myHiddenField.Value = myVar;
}

I am able to access this value in my client script.
If a PostBack occurs, myHiddenField.Value is updated server-side, but
the value client-side always remains the same - the initial value when
the page first loads...

I'm missing something...pointers appreciated..

Thanks in advance
Jul 17 '07 #2
Ensure that you only assign the initial value when the page loads for the
first time:
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
this.myHiddenField.Value = myVar;
}
"hharry" wrote:
Hello All,

I am trying to make use the HiddenField server control to make a
server-side variable visible to a client script.
I set the value of the HiddenField inside of the Page_Load event.

protected void Page_Load(object sender, EventArgs e)
{
this.myHiddenField.Value = myVar;
}

I am able to access this value in my client script.
If a PostBack occurs, myHiddenField.Value is updated server-side, but
the value client-side always remains the same - the initial value when
the page first loads...

I'm missing something...pointers appreciated..

Thanks in advance

Jul 17 '07 #3
On Jul 17, 5:59 am, "Brandon Gano" <bg...@inocompany.comwrote:
What do you mean when you say the value is updated server side? Have you
stepped through with the debugger to be sure? Have you viewed the output
source to make sure the hidden field value is not updated on the client
side?

I tried a simple example based on your scenario, and the values are updated
as expected.

"hharry" <paulquig...@nyc.comwrote in message

news:11**********************@q75g2000hsh.googlegr oups.com...
Hello All,
I am trying to make use the HiddenField server control to make a
server-side variable visible to a client script.
I set the value of the HiddenField inside of the Page_Load event.
protected void Page_Load(object sender, EventArgs e)
{
this.myHiddenField.Value = myVar;
}
I am able to access this value in my client script.
If a PostBack occurs, myHiddenField.Value is updated server-side, but
the value client-side always remains the same - the initial value when
the page first loads...
I'm missing something...pointers appreciated..
Thanks in advance- Hide quoted text -

- Show quoted text -
HI... did you actually initalize your code in side a
if(!ispostback)
{
///here
}

and update it in
if(ispostback)
{
///here
}

can you put your code sample ... just to have a quick look...

Thanks
Md. Masudur Rahman (Munna)
Kaz Software Ltd.
www.kaz.com.bd
http://munnacs.110mb.com

Jul 17 '07 #4
On Jul 16, 7:59 pm, "Brandon Gano" <bg...@inocompany.comwrote:
What do you mean when you say the value is updated server side? Have you
stepped through with the debugger to be sure? Have you viewed the output
source to make sure the hidden field value is not updated on the client
side?

I step-thru the code and the value is updated, but when my client-
script runs, the value is not updated and if I right-click and select
view source, the value has not been updated.
Puzzled..
Jul 17 '07 #5
Please post the relevant code here so we can take a look.
"hharry" <pa*********@nyc.comwrote in message
news:11**********************@i13g2000prf.googlegr oups.com...
On Jul 16, 7:59 pm, "Brandon Gano" <bg...@inocompany.comwrote:
>What do you mean when you say the value is updated server side? Have you
stepped through with the debugger to be sure? Have you viewed the output
source to make sure the hidden field value is not updated on the client
side?


I step-thru the code and the value is updated, but when my client-
script runs, the value is not updated and if I right-click and select
view source, the value has not been updated.
Puzzled..

Jul 17 '07 #6

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

Similar topics

0
by: le_mo_mo | last post by:
Hi, I am trying to insert some data using FormView which works fine but I do not know how to include hiddenfield and bind them in the construct so I can insert information like username, date,...
9
by: Kevin Blount | last post by:
Here's the code I tried, and found it failed... <form runat="server" method="post" name="CreditCardForm" id="CreditCardForm"> <% foreach (object item in Request.Form) { if...
3
by: sklett | last post by:
I've added a HiddenField control to my page and some javascript to show it's value in an alert box when a button is pressed. The value that is displayed in the alert box is correct, but when I...
3
by: Jeff | last post by:
Hey ASP.NET 2.0 Below you see the code I'm having problem with. In the Open_Message event/method I want to get the value of the HiddenField at the row in the repeater control I clicked.... my...
1
by: Milkstr | last post by:
I have a repeating region with a hiddenfield on each line, i want to start a counter in my reapeating reagion so that the hiddenfield becomes unique on each line. So that is the reapeating region goe...
1
by: RSH | last post by:
I have a situation where I have a user control (Called TopOrangeMenu) that has an Hidden HTML Field called "txtU" I am trying to get at the value of that hidden field control from within the...
1
by: KBTibbs | last post by:
My ASP.NET page generates some HTML, then sticks it into a hiddenfield so a javascript can access it and write it to a popup window. I had to disable validation for this page, as HTML inside a...
1
by: win | last post by:
I've created a formview and bind the columns. The column ModifyUser should not be be displayed so that I've modified from Textbos to HiddenField. How can I change the bind value of a Hiddenfield...
7
by: imbirek8 | last post by:
Hi! I would like to write something in Javascript to HiddenField: <asp:HiddenField ID="hiddenMy" runat="server" Value="" /> And in the code behind read this value. But this HiddenField is in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
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)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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.