Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • *Gurus*
Posted

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>

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...