sdlangers Posted June 17, 2003 Posted June 17, 2003 Hi, I need a way of doing this in asp.net <input type=hidden name="amount" value="<%=amount%>"> where amount is on the server codebehind. this was the way to do it in the old asp, but now, even if i declare the variable amount in the pageload event, it still gives me an error saying it is undeclared. the <input> tag is part of a form and cant be made to runat server side thanks for your help danny. Quote
Administrators PlausiblyDamp Posted June 17, 2003 Administrators Posted June 17, 2003 declare the variable as protected in the code behind Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Gurus* Derek Stone Posted June 18, 2003 *Gurus* Posted June 18, 2003 Three other ways of doing the same thing: <script runat="server"> Dim amount As Integer Sub Page_Load(sender As Object, e As EventArgs) amount = 10 ctlAmount.Value = amount.ToString() End Sub </script> <html> <head> <title></title> </head> <body> <form> <input id="ctlAmount" type="hidden" name="amount" value="" runat="server" /> </form> </body> </html> ctlAmount.Attributes("value") = amount.ToString() <script runat="server"> Dim amount As Integer Sub Page_Load(sender As Object, e As EventArgs) amount = 10 End Sub </script> <html> <head> <title></title> </head> <body> <form> <input type="hidden" name="amount" value="<%=amount.ToString()%>" /> </form> </body> </html> Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.