Ashish:
Page.RegisterHiddenField doesn't create a server side control, it just
creates a plain-old <input type="hidden">..so
Page.FindControl("myhiddenField") will never find anything....
If you call RegisterHiddenField twice with the same id, it'll only register
the field once, so:
Page.RegisterHiddenField("myhiddenfield", "hidden")
Page.RegisterHiddenField("myhiddenfield", "hidden")
there'll only be 1 myHiddenField
There's no way to tell which hidden fields have been registered this
way...on postback you can use Request.Form("myhiddenField") to get the
information though
You could always create a server control via:
dim myHiddenField as new HtmlInputHidden()
somePlaceHolder.Controls.Add(myHiddenField)
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"ashish" <> wrote in message
news:...
> If i want to add a hidden field on the page, how can i check whether
> that hidden field exists ?
>
> for example if i do
>
> If Page.FindControl("myhiddenfield") Is Nothing Then
> Page.RegisterHiddenField("myhiddenfield", "hidden")
> End If
>
>
> Dim myHiddenField As HtmlInputHidden = Page.FindControl("myhiddenfield")
> ** this line would throw error
>
>
> how can i know that the hidden field is there before trying to add it ?
>
> TIA
> -ashish
>