[英]Getting a value from a JavaScript function to my ASP.NET / C# Code-Behind
[英]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.