簡體   English   中英

ASP.NET web 形式:顯示值來自 c# 代碼隱藏

[英]ASP.NET web form: display value coming from c# code-behind

我正在使用 Visual Studio 2019,我正在創建一個 web 表單。 我的代碼隱藏使用 sql 腳本從數據庫中提取數據。 我必須在 web 表單中顯示其中一些字段。

例如, project_description是字段之一,它作為ProjDesc存儲在 my.cs 文件中。

在 web 表單中,我有一個用於顯示此字段的文本框:

<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 ,但由於“它在當前上下文中不存在”而突出顯示。

從 my.aspx 文件中調用ProjDesc的正確方法是什么? 是否必須在Text屬性下為 go ?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM