Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to set hidden field values on forms that don't runat="server"?

Posted on 2006-06-21
3
Medium Priority
?
744 Views
Last Modified: 2008-03-04
I've been using the following method for hidden fields:

Page.RegisterHiddenField("HiddenField1","foobar");

I need to post to an external site, so I'm using an HTML submit button.  I need to turn off runat="server" or else the page posts back to itself.  When I do, the RegisterHiddenField code stops working.

I was told I could use the following to create hidden fields:

<asp:HiddenField ID="HiddenField1" runat="server" Value="foobar" />

But that gives me an "Error Creating Control" message saying HiddenField isn't part of the WebControls assembly, probably because I'm using .NET 1.1, but that's what I'm stuck with because I'm using VS 2003.

Is there another way to create a hidden field to which I can dynamically assign values when the page is loaded?

Thanks folks.  This is the last big piece of this application I need to get working.
0
Comment
Question by:dtburdick
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 25

Accepted Solution

by:
nauman_ahmed earned 1000 total points
ID: 16951115
The syntax for hidden field is given below:

<input type=hidden name="fieldName" value="value" runat=server>

There is nothing in VS.NET as asp:HiddenField. I will recommend declaring this field in the ASPX and not adding it in the code-behind. In the code-behind you can set the value as follows:

hiddenField.value = "value"

From javascript its document.forms[0].hiddenFieldName.value = "new Value";

-Nauman.
0
 
LVL 15

Expert Comment

by:GavinMannion
ID: 16951217
You can always just use a normal textbox and make it's visible attribute = false....

It should then work as a normal field..

But if it doesn't need to be dynamic or anything just use the html standard.... as shown above
0
 

Author Comment

by:dtburdick
ID: 16954846
Thank you!  I was running out of hope!

The only thing I'll add is that I needed to identify the object at the top of the .CS page:

protected System.Web.UI.HtmlControls.HtmlInputHidden MYHIDDENOBJECT;

and that the code to modify the contents is case sensitive so it is:

MYHIDDENOBJECT.Value="foobar";

Much thanks!
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question