在什么地方写,怎么写,我要详细的代码!谢谢啦
解决方案 »
- 60分在线等,怎么给用户控件添加事件?
- WebBrowser 怎么控制页面的显示位置
- 注册framework3.5到 iis
- 求.net2005简体中文语言包
- 求助,求助,为什么VS2008里面打\这个反斜杠的时候会出来¥符号啊
- 麻烦各位大哥帮忙更正。
- 坐等 C# socket通信 TCP 数据传输如何检测误码率
- 没写完的俄罗斯(C#版),请高手写一下消层的算法.现在的代码已经可以运行了.但还有点问题.请高手帮忙找找原因.100分相赠!
- C#有一字符串加密问题,望高手赐教
- WPF,UserControl怎么使用触发器呢?
- 一个让人百思不得其解的问题,用timer生成随机数组的问题
- C# 有没有传统风格的列表控件
Public Static SharedProperties
{
public static int SharedNumber;
}然后你的所遇form就可以访问到这个静态类里的SharedNumber了。
using System.Collections.Generic;
using System.Text;namespace WindowsApplication1
{
class Class1
{
public static string str = "aaa"; }
}
public static object m_Object=null;
public static int m_Int=0;
2.定义在Program里面
3.放在资源文件里也可以
……
PUBLIC STATIC 类型 变量名 = 初始值;
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DevExpress.Web.ASPxGridView;
using System.Drawing;
using System.IO;
using System.Web.Configuration;
using System.Drawing.Imaging;
using DevExpress.Web.ASPxUploadControl;
public partial class exam_question_ope : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ASPxGridView1_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
{
int index = Convert.ToInt32(e.Parameters);
string Temp_ID = ASPxGridView1.GetRowValues(index, new String[] { "Choose_ID" }).ToString();
// Session["IssueIDInSession"] = ASPxGridView1.GetRowValues(index, new String[] { "Choose_ID" }).ToString();
}
}
using System;
using System.Collections.Generic;
using System.Text;namespace Program
{
class UserHelper
{
public static int loginId;
}
}以后就可以用UserHelper.loginId可以访问到了
写在声明变量的地方
例:
声明:
……
namespace SetStatic
{
class class1
{
public static int ics = 0;
……
}
}
访问:
在你需要的地方:class1.ics = Convert.toInt32(textbox1.text);//设置
lable1.text = class1.ics.toString();//访问
2.在Program.cs定义一个类的全局静态变量public static string xxxx,调用的时候直接Program.xxxx就可以了
{
public static string Temp_ID
protected void Page_Load(object sender, EventArgs e)
{
} protected void ASPxGridView1_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
{
int index = Convert.ToInt32(e.Parameters);
Temp_ID = ASPxGridView1.GetRowValues(index, new String[] { "Choose_ID" }).ToString();
// Session["IssueIDInSession"] = ASPxGridView1.GetRowValues(index, new String[] { "Choose_ID" }).ToString();
}
private string _temp_ID = string.Empty;
internal string Temp_ID
{
get
{
return this._temp_ID;
}
set
{
if (!string.Equals(this._temp_ID, value))
{
this._temp_ID = value;
this.OnTempIDChanged();
}
}
}//当Temp_ID属性改变时的相关处理
private void OnTempIDChanged()
{
//Do sth...
}
如果是同一个程序集 就直接掉这个 类名称.XXX 否则需要引用类所在程序集
public partial class exam_question_ope : System.Web.UI.Page
{
public static string Temp_ID
protected void Page_Load(object sender, EventArgs e)
{
} protected void ASPxGridView1_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
{
int index = Convert.ToInt32(e.Parameters);
Temp_ID = ASPxGridView1.GetRowValues(index, new String[] { "Choose_ID" }).ToString();
// Session["IssueIDInSession"] = ASPxGridView1.GetRowValues(index, new String[] { "Choose_ID" }).ToString();
}