posted @ 2011-11-20 00:51 God Blue Shadow 阅读(10) 评论(0) 编辑
修改select 的selectedValue或者selectedIndex或者两者,在服务器端还是默认的选择项,想想可能与元素的selected有关,试了一下,果然如此。
aspx代码如此:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtTest" runat="server"></asp:TextBox>
<asp:DropDownList ID="ddlTest" runat="server">
<asp:ListItem Text="1" Value="1" Selected="true"></asp:ListItem>
<asp:ListItem Text="2" Value="1" ></asp:ListItem>
<asp:ListItem Text="3" Value="1"></asp:ListItem>
<asp:ListItem Text="4" Value="4"></asp:ListItem>
<asp:ListItem Text="5" Value="5"></asp:ListItem>
<asp:ListItem Text="6" Value="6"></asp:ListItem>
</asp:DropDownList>
<script type="text/C#" runat="server">
private void foo()
{
btnReturn.Click += new EventHandler(btnReturn_Click);
}
</script>
<script type="text/javascript">
var txt = document.getElementById("<%=txtTest.ClientID %>");
txt.value = "asdfsdf";
var ddl =document.getElementById("<%=ddlTest.ClientID %>");
ddlSelByValue( ddl,1,0);
function ddlSelByIndex( ddl, index )
{
var selIndex = -1;
// check
if( ddl.length < 1 )
{
return;
}
if( index >= ddl.length )
{
return;
}
for(var i=0;i<ddl.length;i++)
{
if( ddl[i].selected == true )
{
selIndex =i;
break;
}
}
if( selIndex != -1 )
{
ddl[selIndex].selected = false;
}
ddl[index].selected = true;
}
function ddlSelByValue( ddl , value ,order)
{
// check
if( ddl == undefined )
{
return;
}
if( value == undefined)
{
return;
}
if ( order == undefined )
{
order = 0;
}
if( order < 0 )
{
return;
}
var selIndex = -1;
var index4Value =[];
// get current selectedIndex and indexs for match the input value
for(var i=0;i<ddl.length;i++)
{
if( ddl[i].selected == true )
{
selIndex =i;
}
if( ddl[i].value == value )
{
index4Value.push(i);
}
}
// process
if( index4Value == undefined || index4Value.length < 1 )
{
return;
}
if( order >= index4Value.length )
{
return;
}
if( selIndex != -1 && selIndex == index4Value[order])
{
return;
}
ddl[ selIndex ].selected = false;
ddl[ index4Value[order] ].selected = true;
}
</script>
<asp:Button ID="btnReturn" runat="server" Text="return" OnClick="btnReturn_Click" />
</div>
</form>
</body>
</html>
CS代码如下:
using System;
using System.Data;
using System.Configuration;
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;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnReturn_Click(object sender, EventArgs e)
{
this.Request.SaveAs("c:\\a.txt", true);
}
}
打开C:\a.txt,我们将会看到以下内容:
POST /WebSite1/Default.aspx HTTP/1.1
Cache-Control: no-cache
Connection: Keep-Alive
Content-Length: 254
Content-Type: application/x-www-form-urlencoded
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, */*
Accept-Encoding: gzip, deflate
Accept-Language: zh-cn
Host: localhost:1230
Referer: http://localhost:1230/WebSite1/Default.aspx
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)
__VIEWSTATE=%2FwEPDwUKLTgxOTUxNjU1N2RkD74GTaa7YkYEXnEtKp8fUvs%2Fo10%3D&txtTest=asdfsdf&ddlTest=6&btnReturn=return&__EVENTVALIDATION=%2FwEWCQK6tuK0AwL9h%2FmcCQKK6%2BCJCAKK6%2BCJCAKK6%2BCJCAKJ6%2BCJCAKO6%2BCJCAKP6%2BCJCAL02tCyAsYjRYHRHKh5VciUq%2FsNDu9bmDaK
__ViewState以前是头部信息,__ViewState及其后面是控件的值,我们可以看到ddlTest=6,6为Value值,如果我们选择第二项或第三项,这个值永远是1,那么在服务器端,ddlTest.SelectedItem永远是第一个。
posted @ 2008-09-16 15:28 God Blue Shadow 阅读(77) 评论(0) 编辑
对于ArcGIS的框架,我相信网上介绍得更多了,现在主要讲怎样安装ArcGIS组件来进行.net二次开发.
我们要装的组件有:ArcSDE,ArcIMS,ArcIMS.ADF.DotNet。
数据库我们采取主流的Oracle9i,我们选择Oracle9.2,但是不能选择Oracle9.0,因为它不能与SDE很好的协作,其它的版本未测试过。Oracle的安装过程略。
有了这个数据库基础了,我们可以来安装ArcSDE,选择ArcSDE for Oracle9i。按照默认的配置安装就可以了。当然,授权文件是必不可少,如果没有,上网找吧。
有了ArcSDE这个数据桥,我们来接着装ArcIMS这个大块头。
1.我们要装JRE,在ArcIMS的安装盘中可以找到I:\ArcExplorer_Java\Disk1\InstData\VM\Support\JRE\jre-1_5_0_06-windows-i586-p.exe,安装它。
对系统进行配置:添加系统变量 java_home , 值为C:\Program Files\Java\jre1.5.0_06
追加Path变量,值为:%java_home%\bin;
这样,ArcIMS就可以轻松的找到JRE了。
2.装ServletExec,可以在ArcIMS的安装盘中可以找到:I:\ServletExec\ServletExec_ISAPI_50013.exe,与Windows IIS打交道,肯定要选择ISAP啦。安装的过程中会让你设置用户名和密码的,安装完成后链接http://localhost/servletexec/admin ,如果可以用你刚才用户名和密码登陆就表示你ServletExec安装OK了。
3.安装ArcIMS,默认安装就可以了,在安装的过程中,提示你输入当前登录密码之类的;出现很多选择项的对话框,什么IIS,Apach,Tomcat之类的,选择 IIS + ServletExec。其它的地方按照提示默认安装就可以了。
4,安装完成后,重启IIS.
5.测试ArcIMS安装是否成功,选择开始->程序->ArcGIS->ArcIMS->Diagnostics,点击“1”按钮和“2”按钮,如果都出现Success字样,表明安装已经完成OK了。
6,为了将ArcSDE与ArcIMS协作好,必须定义系统变量:
对系统进行配置:添加系统变量 SDEHOME, 值为D:\arcgis\ArcIMS\Server (ArcIMS的安装目录下的Server)
追加Path变量,值为:%SDEHOME%\bin;
7,安装ADF.Dotnet
posted @ 2008-09-08 15:43 God Blue Shadow 阅读(581) 评论(0) 编辑
posted @ 2008-08-19 18:49 God Blue Shadow 阅读(429) 评论(1) 编辑
SendKeys模拟键盘的操作,设置一定的键值,便可以自动控制。但是我们在使用的过程中,发现SendKeys不支持空格键,在很多的应用场景,都需要使用空格键,所以只好通过反射的方式将其调整。
代码如下:
Type typeForKeywords = Type.GetType("System.Windows.Forms.SendKeys+KeywordVk[], System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
Type typeForKeywordItem = Type.GetType("System.Windows.Forms.SendKeys+KeywordVk, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
object objNewKey = Activator.CreateInstance(typeForKeywordItem, "SPACE", 0x20);
Type typeForSendKeys = typeof(SendKeys);
FieldInfo fieldForkeywords = typeForSendKeys.GetField("keywords", BindingFlags.NonPublic | BindingFlags.GetField | BindingFlags.Static);
object objKeys = fieldForkeywords.GetValue(null);
Type typeForlistForKeyword = Type.GetType("System.Collections.Generic.List`1[[System.Windows.Forms.SendKeys+KeywordVk, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
object objForTmpKeyWords = Activator.CreateInstance(typeForlistForKeyword);
MethodInfo mi = typeForlistForKeyword.GetMethod("Add");
foreach (object var in (Array)objKeys)
{
//list.Add(var);
mi.Invoke(objForTmpKeyWords, new object[] { var });
}
//list.Add(key);
mi.Invoke(objForTmpKeyWords, new object[] { objNewKey });
mi = typeForlistForKeyword.GetMethod("ToArray");
object objArray = mi.Invoke(objForTmpKeyWords, null);
fieldForkeywords.SetValue(null, objArray);
posted @ 2008-03-13 15:26 God Blue Shadow 阅读(764) 评论(1) 编辑
posted @ 2008-02-18 10:36 God Blue Shadow 阅读(200) 评论(0) 编辑
posted @ 2007-10-24 16:49 God Blue Shadow 阅读(1062) 评论(1) 编辑
posted @ 2007-07-05 21:48 God Blue Shadow 阅读(413) 评论(1) 编辑
posted @ 2007-06-28 18:02 God Blue Shadow 阅读(99) 评论(0) 编辑
