【发布时间】:2019-10-18 15:44:26
【问题描述】:
我正在使用 Visual Studio 2019 创建 Web 表单。我的代码隐藏使用 sql 脚本从数据库中提取数据。我必须在网络表单中显示其中一些字段。
例如,project_description 是其中一个字段,在我的 .cs 文件中存储为 ProjDesc。
在网络表单中,我有一个文本框用于显示该字段:
<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>
在上面写着<insert variable> 的地方,我尝试使用变量名ProjDesc,但是因为“它在当前上下文中不存在”而被突出显示。
从我的 .aspx 文件中调用 ProjDesc 的正确方法是什么?它必须在Text 属性下吗?
【问题讨论】:
标签: c# asp.net webforms code-behind