[英]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.