[英]How to pull values/strings from code behind into the .aspx page
大家好,我的代碼在后面
//a == the viewing month
//b == the x or 1 which will be use to add or subtract depending on the action
//c == the previous month
//d == the next month
int a = int.Parse(actual.Text);
int b = int.Parse("1");
int c;
int d;
c = a - b; //This provides the previous month for the link
d = a + b; //This provides the next month for the link
現在在頁面加載時,我想將“ c”和“ d”的值拉入.aspx頁面的錨點中。 我已經嘗試了無數種方法,但是我做錯了,這有可能嗎? 如果是這樣怎么辦?
謝謝
如果要使用頁面中的數字,則必須將它們聲明為受保護的,並確保不在頁面上使用方法聲明它們。 您可以在頁面加載時或在頁面中可能具有的不同控件調用的事件內部計算它們。
比您在.aspx頁上可以使用的
<%= c.ToString()%>
<%= d.ToString()%>
您可以將其添加到標簽或文本框中:
在頁面加載時
Label1.Text = c;
問候
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.