Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing Data from codeBehind .VB file

Status
Not open for further replies.

PoppapumpJ

Programmer
Dec 17, 2001
86
US
I have a .aspx page with a codeBehind .VB file.

Everything is running fine now, However I need to add a new form to the ASPX that directs it's data to another server. I've not found a good way to add a new form so I thought I would just write it in the html. However, I'm having trouble getting the data from the .vb file to the .aspx.

This is what the .aspx code looks like

<form method=&quot;post&quot; action=&quot;AnotherServer.com/getData.asp&quot;>
<input type=&quot;hidden&quot; name=&quot;itemname&quot; value=<%=strItemName%>>
</form>



strItemName is a variable in the .vb that I would like to populate into the .aspx. Any ideas on how to do this.

thanks
 
The general design principle you should use here is to declare that with the runat=server declaration, and then you can just set it in the code behind:

<input type=&quot;hidden&quot; name=&quot;itemname&quot; id=itemName runat=server>

~~~~~~
'code behind (declaration area)
protected withevents itemName as system.web.ui.htmlControls.htmlInputHidden

~~~~~~
'in some sub, possibly page_load
itemName = strItemName


Separate your interface from your implementation, and try to avoid <%= at all costs. It's crutching yourself on the old technology, and the more you use the new design principles, the more ideas you'll get on how to improve your web app designs. Spaghetti code is dead! :)

paul
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top