Wednesday, January 2, 2008

Page.RegisterHiddenField Method

This article explains the Page.RegisterHiddenField Method.

From MSDN library’s explanation, Page.RegisterHiddenField method allows server controls to automatically register a hidden field on the form. The field will be sent to the page when the HTML Form servers control is rendered.

This method takes 2 parameters:
hiddenFieldName – The unique name of the hidden field to be rendered
hiddenFieldInitialValue – The value to be emitted in the hidden form

Please take note that if you use this method twice with the same id with different value in your page, it will only register the first one.

For example:
Page.RegisterHiddenField(“field_1”, “value_1”);
Page.RegisterHiddenField(“field_1”, “value_2”);


Value_1 will be rendered while the second call is ignored.

On postback, you can use Request. Form(“field_1”) to get the data of the string result.

Cheers!

0 comments:

 

Get paid for your opinions! Click on the banner above to join Planet Pulse. Its totally free to sign up, and you can earn UNLIMITED. Find out more by visiting PLANET PULSE.
Sign up for PayPal and start accepting credit card payments instantly. http://www.emailcashpro.com
July Code Blog Copyright © 2010 Blogger Template Designed by Bie Blogger Template