大家好,我在代码后面有这段代码
//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;