I am working with Visual Studio 2019, where I am creating a web form. My code-behind pulls data from a database using a sql script. I have to display some of these fields in the web form.
For instance, project_description
is one of the fields, which is stored as ProjDesc
in my .cs file.
In the web form, I have a text box intended to display this field:
<td class="auto-style29"><b>Project description</b></td>
<td class="auto-style5"><asp:TextBox Text="<insert variable>" ID="txtProjTitle" runat="server" Width="768px" Height="26px" ReadOnly ="true" Enabled="false" CssClass="auto-style16"></asp:TextBox></td>
Where it says <insert variable>
, I tried to use the variable name ProjDesc
, but this was highlighted because "it does not exist in the current context".
What's the correct way of recalling ProjDesc
from my .aspx file? Does it have to go under the Text
properties?
If you are using web forms then one way to set the text of your textbox from the aspx is in an event of the web page, probably the same event that is firing the SQL script.
txtProjTitle.Text = ProjDesc