?
Solved

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

Posted on 2006-06-21
3
Medium Priority
?
736 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses
Course of the Month13 days, 14 hours left to enroll

801 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