aspx.cs内在哪怎么定义变量,使其可以在整个aspx.cs内可用?麻烦说详细点啊~~
解决方案 »
- 我用C#做了个记事本,用richTextBox1.LoadFile()的方法打开windows的记事本显示是乱码,向各位高手请教该用什么打开方法可以实现?
- 求随机数生成
- [百分]求Castle1.0.3的代码生成器
- 求解:输入字符串的格式不正确。
- c# winfrom用户登陆选择不同公司别
- 求一条正则,取出“0_341_342_8” 中最后一个“_”前面的字符342。
- 怎样把一个结果集SQL语句查询结果rs从form1.cs传到form2.cs里
- 如何实现如DoNet起始页那样的窗体?
- 兄弟们!给你们下跪了!(如何获取CHECKEDLISTBOX中已勾选的项的value)
- 哪位大侠看看这是怎么回事?
- winform TreeView如何避免生成重复节点?
- 截取括号之中的值的方法是什么?
{
private int x;
...
}
在任何地方都可以用了
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
namespace S.Sams.GoogleMap.Web
{
/// <summary>
/// MapPageBase 处理了 // onload="initialize()" onunload="GUnload()" 这两个事件, 如果不使用继承, 请自行处理该事件!
/// </summary>
public partial class Default : MapPageBase
{ #region 数据初始化
private string AppID
{
get { return appid.Text; }
} private Init GetSystemInit
{
get
{
Init init = new Init(showmymap2.Text, int.Parse(scaleint.Text), MapType.Normal, MapControl.Full);
init.EnabledScrollWheelZoom = EnabledScrollWheelZoom.Checked;
init.IsMapScale = mapscale.Checked;
init.IsMapView = mapview.Checked;
init.IsMapType = IsMapType.Checked;
init.IsMapControls = IsMapControls.Checked;
init.IsShowCenterMsg = IsShowCenterMsg.Checked;
init.MapViewWidth = int.Parse(MapViewWidth.Text);
init.MapViewHeight = int.Parse(MapViewHeight.Text);
init.IsAddLine = IsAddLine.Checked;
init.IsAddLineEnd = IsAddLineEnd.Checked;
init.AddLine16Color = AddLine16Color.Text;
init.AddLineWidth = int.Parse(AddLineWidth.Text);
init.Customlabel = new CustomLabel() {
isEnabledCusstomLabel = isEnabledUserCusstom.Checked,
isOnlyOnePoint = isUsePointOne.Checked,
PointMsg = UsePointOneMsg.Text,
JavascriptFunction = FunctionName.Text,
isClickShowMsg = isClickShowMsg.Checked
};
init.EnableGoogleBar = EnableGoogleBar.Checked;
init.EnableGoogleBarShow = EnableGoogleBarShow.Checked;
return init;
}
} private List<Label> GetLabels
{
get
{
//在这里想从数据库里调值赋值,数据库中存的数据个数不定 return new List<Label>() {
new Label(){
TabMsg = new List<Msg>() {
new Msg("环境", L1_msg.Text),
new Msg("饮食", "仅次于一般"),
new Msg("一起飞","")
},
IsCenter = L1_iscenter.Checked,
LabelImage = L1_img.Text,
X = double.Parse(L1_x.Text),
Y = double.Parse(L1_y.Text),
ZoomIn = int.Parse(L1_zoomin.Text),
IsShowMapView = L1_mapview.Checked,
Visible = L1_visible.Checked,
MsgMaxTitle = L1_maxtitle.Text,
MsgMaxContent = L1_maxcontent.Text
},
new Label(){
Msg=L2_msg.Text,
IsCenter = L2_iscenter.Checked,
LabelImage = L2_img.Text,
X = double.Parse(L2_x.Text),
Y = double.Parse(L2_y.Text),
ZoomIn = int.Parse(L2_zoomin.Text),
IsShowMapView = L2_mapview.Checked,
Visible = L2_visible.Checked,
MsgMaxTitle = L2_maxtitle.Text,
MsgMaxContent = L2_maxcontent.Text
}
}
};
}
} private List<MapLine> GetMapLines
{
get {
return new List<MapLine>(){new MapLine() {
Labels = GetLabels,
LineWidth = int.Parse(GetMapLines_Width.Text),
Color16Code = GetMapLines_Color.Text}
};
}
} #endregion
//……}
/// cs后台文件,针对页面事件进行响应
/// </summary>
public partial class SignWeb : System.Web.UI.Page
{
//声明页面元素
protected string strXuHao;
protected void Page_Load(object sender, EventArgs e)
{
}
}此处的strXuHao定义的变量,即可在整个.cs里使用。
并且,在前台.aspx内可获取,使用 <%=strXuHao%>
/// cs后台文件,针对页面事件进行响应
/// </summary>
public partial class SignWeb : System.Web.UI.Page
{
//声明页面元素
protected string strXuHao;
protected void Page_Load(object sender, EventArgs e)
{
}
}此处的strXuHao定义的变量,即可在整个.cs里使用。
并且,在前台.aspx内可获取,使用 <%=strXuHao%>