Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I'm using the hidden textbox for the first time
HTML
< input type="hiddden"/>

I haven't used it before. Application requires that a value from the database bound to a hidden input tag. I tried my best but didn't get solution. Please help me out.
Given below is my code in the .aspx file:
ASP.NET
<input id="Item_ID" type="hidden" name="Item_ID" runat="server"/>

and in the .cs file:
C#
int.TryParse(Item_ID.Value, out subpageid);
Subpage subpage = subpageid > 0 ? new Subpage(subpageid) : new Subpage();


[Edit: Codehawkz]Fixed his spellings and added asp.net tag[/Edit]
Posted
Updated 19-Sep-12 1:53am
v4
Comments
DaveAuld 19-Sep-12 7:17am    
How to use? that is not an acceptable title. Hidden has 2 'd's not 3. Hi has one 'i' and I take it Frds is meant to be Friends?

Hey there,

If you don't assign a value to the hidden control then it won't return a value on postback. Simple as that :)
ASP.NET
<input id="Item_ID" type="hidden" name="Item_ID" runat="server" value="2" />

Please, See the value attribute I've set.

What DaveAuld is trying to tell you is that, this is a professional forum, not a SMS service. So use correct spellings to the best of your strength.

@DaveAuld: Perhaps, he might not be fluent in using his english. Just in case, cut him some slack :)

Hope this helps, regards
 
Share this answer
 
Hi,

You can bind value to hidden field directly like,
value = '<%= YourServerSideVariable%>'

Here note that "YourServerSideVariable" must be public.


Thanks
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900