Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

function chek( chkAll )
??? {
??????? var obj = document.aspnetForm.getElementsByTagName(“input”);
?? ??? ??? ?
?? ??? ??? ?for (var i=0;i<obj.length;i++)
?? ??? ??? ?{
?? ??? ??? ?
?? ??? ??? ??? ?var e = obj[i];
?? ??? ??? ??? ?if (e.id.indexOf(“chkItem”)>=0 && e.type==”checkbox”)
?? ??? ??? ??? ??? ?e.checked = chkAll.checked;
?? ??? ??? ?}
?? ??? ??? ?
??? }

头部:
? <input type=”checkbox” id=”chkAll” onclick=”CheckAll( this );” />

子项:
<asp:CheckBox ID=”chkItem” runat=”server” />


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

都有一个onclick事件,当结果返回true时才会执行
“>删除

< input type = "submit" ID="Button1" Text="提交" onsubmit ="return confirm('Ok to post?')" />


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
function PopupCalendar(InstanceName)
{
///Global Tag
this.instanceName=InstanceName;
///Properties
this.separator="-"
this.oBtnTodayTitle="Today"
this.oBtnCancelTitle="Cancel"
this.weekDaySting=new Array("S","M","T","W","T","F","S");
this.monthSting=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
this.Width=200;
this.currDate=new Date();
this.today=new Date();
this.startYear=1970;
this.endYear=2010;
///Css
this.normalfontColor="#666666";
this.selectedfontColor="red";
this.divBorderCss="1px solid #BCD0DE";
this.titleTableBgColor="#98B8CD";
this.tableBorderColor="#CCCCCC"
///Method
this.Init=CalendarInit;
this.Fill=CalendarFill;
this.Refresh=CalendarRefresh;
this.Restore=CalendarRestore;
///HTMLObject
this.oTaget=null;
this.oPreviousCell=null;
this.sDIVID=InstanceName+"_Div";
this.sTABLEID=InstanceName+"_Table";
this.sMONTHID=InstanceName+"_Month";
this.sYEARID=InstanceName+"_Year";
this.sTODAYBTNID=InstanceName+"_TODAYBTN";
}
function CalendarInit() ///Create panel
{
var sMonth,sYear
sMonth=this.currDate.getMonth();
sYear=this.currDate.getYear();
htmlAll="";
document.write(htmlAll);
this.Fill(); 
}
function CalendarFill() ///
{
var sMonth,sYear,sWeekDay,sToday,oTable,currRow,MaxDay,iDaySn,sIndex,rowIndex,cellIndex,oSelectMonth,oSelectYear
sMonth=this.currDate.getMonth();
sYear=this.currDate.getYear();
sWeekDay=(new Date(sYear,sMonth,1)).getDay();
sToday=this.currDate.getDate();
iDaySn=1
oTable=document.all[this.sTABLEID];
currRow=oTable.rows[1];
MaxDay=CalendarGetMaxDay(sYear,sMonth);
oSelectMonth=document.all[this.sMONTHID]
oSelectMonth.selectedIndex=sMonth;
oSelectYear=document.all[this.sYEARID]
for(i=0;iMaxDay)break;
currRow = oTable.rows[rowIndex];
cellIndex = 0;
if(rowIndex==1)cellIndex = sWeekDay;
for(;cellIndex"+iDaySn+"";
this.oPreviousCell=currRow.cells[cellIndex];
}
else
{
currRow.cells[cellIndex].innerHTML=iDaySn; 
currRow.cells[cellIndex].style.color=this.normalfontColor;
}
CalendarCellSetCss(0,currRow.cells[cellIndex]);
iDaySn++;
if(iDaySn>MaxDay)break; 
}
}
}
function CalendarRestore() /// Clear Data
{ 
var i,j,oTable
oTable=document.all[this.sTABLEID]
for(i=1;i11)
{
nextYear=nowYear+1;
nextMonth=0;
}
else 
{
nextYear=nowYear; 
}
currDate=new Date(nowYear,nowMonth,1);
nextDate=new Date(nextYear,nextMonth,1);
theMaxDay=(nextDate-currDate)/(24*60*60*1000);
return theMaxDay;
}
function CalendargetPos(el,ePro) /// Get Absolute Position
{
var ePos=0;
while(el!=null)
{ 
ePos+=el["offset"+ePro];
el=el.offsetParent;
}
return ePos;
}
function CalendarDblNum(num)
{
if(num < 10) 
return "0"+num;
else
return num;
}
function CalendarCancel(oInstance) ///Cancel
{
var CalendarDiv=document.all[oInstance.sDIVID];
CalendarDiv.style.display="none"; 
}


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

调用方法:

<HTML>
<HEAD>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″>
<meta http-equiv=”Content-Language” content=”zh-cn”>
<TITLE></TITLE>
<script language=”javascript” src=”calendar.js” ></script>
</head>
<BODY >
<script >
var oCalendarEn=new PopupCalendar(“oCalendarEn”);??? //初始化控件时,请给出实例名称如:oCalendarEn
oCalendarEn.Init();
?
var oCalendarChs=new PopupCalendar(“oCalendarChs”);??? //初始化控件时,请给出实例名称:oCalendarChs
oCalendarChs.weekDaySting=new Array(“日”,”一”,”二”,”三”,”四”,”五”,”六”);
oCalendarChs.monthSting=new Array(“一月”,”二月”,”三月”,”四月”,”五月”,”六月”,”七月”,”八月”,”九月”,”十月”,”十一月”,”十二月”);
oCalendarChs.oBtnTodayTitle=”今天”;
oCalendarChs.oBtnCancelTitle=”取消”;
oCalendarChs.Init();
</script>
<br><br><br><br>
   <input readonly type=”text” name=”dd” id=”aa” onclick=”getDateString(this,oCalendarEn)” value=”English Version”>
<br><br><br><br>
   <input readonly type=”text” name=”dd” id=”aa” onclick=”getDateString(this,oCalendarChs)” value=”中文界面版”>??????????????????????????????????
</BODY>
</HTML>


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58



Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

Response输出指定内容,去掉页面自带的内容

//下面的方法,无论当前页面是什么内容,都只输出自己指定的数据。
Response.Clear(); //清除页面前的内容
Response.Write(“hahahahahahahahahhahahahahahahahhahahahaha”); //指定的内容
Response.End(); //之后的内容不再输出


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
   抓取IP

    REMOTE_ADDR:访问网站的最新的一个IP地址
    HTTP_X_FORWARDED_FOR:中转IP集合即 从出发点到网站前的IP集合,以逗号分开
    1,若直接访问网站,不经过代理,则REMOTE_ADDR为真实IP,HTTP_X_FORWARDED_FOR为空
    2,若使用代理访问网站,则REMOTE_ADDR为最后一个经过的代理IP地址,而HTTP_X_FORWARDED_FOR集合中第一个为真实IP
    由上得出抓取真实IP的方法为:
         private string GetIP()
        {
            if (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null)
            {
                return Request.ServerVariables["HTTP_X_FORWARDED_FOR"].Split(new char[] { ',' })[0];
            }
            else
            {
                return Request.ServerVariables["REMOTE_ADDR"];
            }
        }

    注:REMOTE_ADDR此值是不可修改的,因为网站要与代理服务器通信,要给它传数据,若可修改,那么代理服务器就收不到数据了,因此若通过REMOTE_ADDR得到IP,那么此IP一定是真实的。
          HTTP_X_FORWARDED_FOR值是可以修改的,若通过此值取真实IP,有可能是篡改的非真实IP.不过,对于大访问量的网站来说,大部分的客户都是合法的,只有极少的一部分通过篡改IP的方式去访问,在此种情况下,可以适用上述方法得到IP
    不过对于网上投票那种,篡改IP的方式则很有空间,对于此种,就不能再通过IP去确定是不是同一人点击之类,可以写一个加密的cookie来识别。

    //篡改HTTP_X_FORWARDED_FOR
    static void Main(string[] args)
    {
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(
    "http://localhost:7867/MyTestWebSite/UserIP.aspx");
    request.Headers.Add("REMOTE_ADDR", "192.168.5.88");
    request.Headers.Add("VIA", "ghj1976");
    request.Headers.Add("X_FORWARDED_FOR", "0.0.0.0");
    HttpWebResponse response = (HttpWebResponse)request.GetResponse();
    StreamReader stream = new
    StreamReader(response.GetResponseStream());
    string info = stream.ReadToEnd();
    stream.Close();
    response.Close();
    request = null;
    Console.Write(info);
    Console.ReadLine();
    }



Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

1,工程都有一*.csproj,直接添加即可。
?2,对于网站,先用IIS指向此网站,然后在解决方案添加的时候 添加现有网站-本地IIS 找到网站,加上即可。


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

原理:在on blur 或 onkeydown 时显示调用 _doPoastBack事件,回访到服务器端,要执行对应的哪个方法,在前台加hidden指定
如: function btnClick( btn ){
??????????? if (? event.keyCode == 13 &&? btn != undefined ){
??????????????? //btn.click();
??????????????? document.getElementById(“myHidState”).value = btn.id;? //设置input type = ‘hidden’ 的值
??????????????? __doPostBack(btn.id,””);
??????????? }
??????? }
在后台 load时就可据 Request.Forms[“myHidStateName”] 的值要执行对应的方法


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

? <input type=”text” id = “Text1″ name=”myText111” />
在后台用:Request.Form[“myText111”] 调用前台的值

遍历页面传来的所有值
int loop1;
NameValueCollection coll=Request.Form;?
string[] arr1 = coll.AllKeys;
for (loop1 = 0; loop1 < arr1.Length; loop1++)
{ Response.Write(“Form: ” + arr1[loop1] + “<br>”); }


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

?

?<input?type=”hidden”?name=”__EVENTTARGET”?id=”__EVENTTARGET”?value=””?/> <input?type=”hidden”?name=”__EVENTARGUMENT”?id=”__EVENTARGUMENT”?value=””?/> function?__doPostBack(eventTarget,?eventArgument)?{ if?(!theForm.onsubmit?||?(theForm.onsubmit()?!=?false))?{ theForm.__EVENTTARGET.value?=?eventTarget; theForm.__EVENTARGUMENT.value?=?eventArgument; theForm.submit(); } }

1,eventTarget? 代表控件ID, eventArgument代表控件对应的数据 可用: Request.Form[“__EVENTTARGET”] 形式获取ID,参数。特别在用CheckBoxList时,在其OnSelectedIndexChanged事件中可通过如下方式获取点击的CheckBox:
?? ? string ClickedItem = Request.Form[“__EVENTTARGET”];//得到用户点击的是哪个
????? ClickedItem = ClickedItem.Split(‘$’)[1];//进行拆分处理
???? chkDepartlist.Items[StringHelper.FormatBlankStringToint(ClickedItem)].Value) //当前点击的CheckBox

2, Button与ImageButton不可通过上述方式得到ID,因为他们没有调用 _doPostBack 方法,是直接submit的方式
?? 不过可用如下方式替换:
?? ???? <input?type=”button”?id=”Button2″?value=”Press?me”?onclick=”DoPostBack()”?/>?? <!–显示调用–>
??? ??? ?<script?language=”javascript”?type=”text/javascript”> ?
?? ??? ??? ??? ?function?DoPostBack()? { ??__doPostBack(‘Button2′,’My?Argument’);????? } ?
?? ??? ??? ?</script> string?passedArgument?=?Request.Params.Get(“__EVENTARGUMENT”);


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

维护着Application这个类,指示着在程序启动关闭、session启动关闭可做的事情。
如:Application_Start 、Session_Start


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

int i = (int)Keys.F1; //112
MessageBox.Show(Enum.GetName(typeof(Keys), i)); //F1


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58
public static string GetValue(string AppKey)
        {
            try
            {
                string AppKeyValue;
                AppKeyValue = System.Configuration.ConfigurationSettings.AppSettings.Get(AppKey);
                return AppKeyValue;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void SetValue(string AppKey, string AppValue)
        {
            //System.Configuration.ConfigurationSettings.AppSettings.Set(AppKey,AppValue);
            XmlDocument xDoc = new XmlDocument();
            xDoc.Load(System.Windows.Forms.Application.ExecutablePath + ".config");

            XmlNode xNode;
            XmlElement xElem1;
            XmlElement xElem2;
            xNode = xDoc.SelectSingleNode("//appSettings");

            xElem1 = (XmlElement)xNode.SelectSingleNode("//add[@key='" + AppKey + "']");
            if (xElem1 != null) xElem1.SetAttribute("value", AppValue);
            else
            {
                xElem2 = xDoc.CreateElement("add");
                xElem2.SetAttribute("key", AppKey);
                xElem2.SetAttribute("value", AppValue);
                xNode.AppendChild(xElem2);
            }
            xDoc.Save(System.Windows.Forms.Application.ExecutablePath + ".config");
        }


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

?1,<asp:button ? id=”x” ? runat=”server” ? OnClientClick=”this.disabled=true;document.post.submit();” ? /> ?
? ?
?? 2,设置一全局JS变量
var hasSubmit = 0;
。。。。{
?? ? if ( hasSubmit == 0 ){
??????????????? hasSubmit = 1;
??????????????? return true;
??????????? }else{
??????????????? return false;
??????????? }
}


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

主要是前一页面的编码格式与后一页面接收时不同造成的,可以在前一页面编码,后一页面解码
编码:System.Web.HttpUtility.UrlEncode(str, Encoding.GetEncoding(“GB2312”));
解码:System.Web.HttpUtility.UrlDecode(aa,System.Text.Encoding.GetEncoding(“Gb2312”));


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

用\n是不可以的,要用\r\n,主要是因为TextBox运行在Windows上。Windows能够显示的换行必须由两个字符组成:carriage return & line feed,也就是必须是”\r\n”。
为了保证可跨平台,最好用: Environment.NewLine

注:Console, WebForm用 /n是正常的

Environment方法:

1.获取操作系统版本(PC,PDA均支持)
Environment.OSVersion

2.获取应用程序当前目录(PC支持)
Environment.CurrentDirectory

3.列举本地硬盘驱动器(PC支持)
string [] strDrives=Environment.GetLogicalDrives();
foreach(string strDrive in strDrives)
{
?????
}

4.获取.Net Framework版本号(PC,PDA均支持)
Environment.Version

5.获取机器名(PC支持)
EnvironMent.MachineName

6.获取当前环境换行符(PC支持)
Environment.NewLine

7.获取处理器个数(PC支持)
Environment.SystemDirectory

8.获取当前登录用户(PC支持)
Environment.UserName

9.获取系统保留文件夹路径(PC,PDA均支持)
Environment.GetFolderPath(Environment.SpecialFolder对象)
Environment.SpecialFolder对象提供系统保留文件夹标识,例如:Environment.SpecialFolder.Desktop表示桌面文件夹的路径

10.获取命令行参数(PC支持)
string [] strParams=Environment.GetCommandLineArgs();
foreach(string strParam in strParams)
{
?????
}

11.获取系统环境变量(PC支持)
System.Collections.IDictionary dict=Environment.GetEnvironmentVariables();
string str=dict[“Path”].ToString();

12.设置环境变量(PC支持)
Environment.SetEnvironmentVariable(“Path”, “Test”);

13.获取域名(PC支持)
string strUser = Environment.UserDomainName;

14.获取截至到当前时间,操作系统启动的毫秒数(PDA,PC均支持)
str = Environment.TickCount.ToString();

15.映射到当前进程的物理内存数
str = Environment.WorkingSet.ToString();

16.退出应用程序
Environment.Exit(0)


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

1,新建:右键新增项-外观文件
2,编辑:如
注:没有ID属性
3,应用:在web.config中的 ……….. 这样就为整个网站的button指定了样式
页面级引用: <%@ Page Theme="Skin1" ......... 4,新建多个主题,选择改变,在程序中指定 protected void Page_PreInit(object sender, System.EventArgs e) { try { Theme = "Skin1"; } catch { // Empty strings result in no theme being applied. Theme = ""; } }


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

中直接加cssClss设置边框,则显示的只是整个table的四边有效果,内部没有线。
若想内部也有边框方法:
(1)this.GridView1.Attributes.Add(“bordercolor”, “red”);
(2)在GridView编辑列里的字段ItemStyle里面设才有用
(3)设置css时为td加上样式
table.gridview_m
{
border-collapse: collapse;
border:solid 1px #93c2f1;
width:98%;
font-size:10pt;
}

table.gridview_m td,th
{
border-collapse: collapse;
border:solid 1px #93c2f1;
font-size:10pt;
}