环境:VS2005,怎样获取:1,客户端的IP地址;2,客户端显示器的显示模式(是800*600还是1024*768)? 谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 string Address=Request.UserHostAddress http://topic.csdn.net/t/20030206/16/1406864.html window.document.all.item("Text1").value=screen.width; window.document.all.item("Text2").value=screen.height; 这个我不知道放哪里? ip地址string Address=Request.UserHostAddress;分辨率只能在客户端用js获取. 你可以用viewstate,url传递,ajax等把值返回给服务器端进行处理<script type="text/javascript"> alert(screen.width); alert(screen.height); </script> 1、首先在页面上建两个html控件: <INPUT id="Text1" style="BORDER-RIGHT: #9999cc thin solid; BORDER-TOP: #9999cc thin solid; Z-INDEX: 121; LEFT: 376px; BORDER-LEFT: #9999cc thin solid; WIDTH: 82px; BORDER-BOTTOM: #9999cc thin solid; POSITION: absolute; TOP: 14px; HEIGHT: 21px" type="text" size="8" value="1" name="Text1" runat="server"> <INPUT id="Text2" style="BORDER-RIGHT: #9999cc thin solid; BORDER-TOP: #9999cc thin solid; Z-INDEX: 121; LEFT: 376px; BORDER-LEFT: #9999cc thin solid; WIDTH: 82px; BORDER-BOTTOM: #9999cc thin solid; POSITION: absolute; TOP: 14px; HEIGHT: 21px" type="text" size="8" value="1" name="Text2" runat="server"> 其中,runat="server"是在设计器中右击选作为服务器控件运行。用来存放分辩率。 2、在客户端脚本中: window.document.all.item("Text1").value=screen.width; window.document.all.item("Text2").value=screen.height; 这样,分辨率就存放在控件中了。 注意:此脚本应放在aspx代码的底部,即</body>上端,否则在页面初始加载时因这两个控件还未生成,会报错。 3、在服务器端代码需要用到的地方: string pagewidth=Request.Form["Text1"].ToString(); string pageheight=Request.Form['Text2"].ToString(); 以上是COPY的,请问:string pagewidth=Request.Form["Text1"].ToString(); string pageheight=Request.Form['Text2"].ToString(); 是不是这样的:<script type="text/javascript">{string pagewidth=Request.Form["Text1"].ToString(); string pageheight=Request.Form['Text2"].ToString(); }</script>我是这样,允许错误:未将对象引用设置到对象的实例。 说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。 <script type="text/javascript">{string pagewidth=Request.Form["Text1"].ToString(); string pageheight=Request.Form['Text2"].ToString(); }</script>这个有错吗? ....这个是javascript作用块.string pagewidth=Request.Form["Text1"].ToString(); 是c#的语法. 不同的概念的东西强烈建议你熟悉一下b/s的流程和大概的思路 如何拼接参数化的SQL语句??? asp.net如何打包成exe 弱弱问一个简单的路径问题..在线等 GridView问题 如何将页面导出为Excel?? 如何解决这样的并发访问? 水晶报表导出PDF打印字体变小问题。 jquery.fileupload上传ASP.NET mvc方法中怎么获取不到文件!!!! 看看这个过程吧,如能调试到正常执行,相送(50)分~~! 如何把在数据库搜到的数据添到事先设定好的相应的word表格当中!!请教应该如何实现!!! 请问:System.InvalidCastException: 指定的转换无效 是怎么回事?? 关于集合列表的一个问题
window.document.all.item("Text2").value=screen.height;
这个我不知道放哪里?
string Address=Request.UserHostAddress;分辨率只能在客户端用js获取. 你可以用viewstate,url传递,ajax等把值返回给服务器端进行处理
<script type="text/javascript">
alert(screen.width);
alert(screen.height);
</script>
<INPUT id="Text1" style="BORDER-RIGHT: #9999cc thin solid; BORDER-TOP: #9999cc thin solid; Z-INDEX: 121; LEFT: 376px; BORDER-LEFT: #9999cc thin solid; WIDTH: 82px; BORDER-BOTTOM: #9999cc thin solid; POSITION: absolute; TOP: 14px; HEIGHT: 21px" type="text" size="8" value="1" name="Text1" runat="server">
<INPUT id="Text2" style="BORDER-RIGHT: #9999cc thin solid; BORDER-TOP: #9999cc thin solid; Z-INDEX: 121; LEFT: 376px; BORDER-LEFT: #9999cc thin solid; WIDTH: 82px; BORDER-BOTTOM: #9999cc thin solid; POSITION: absolute; TOP: 14px; HEIGHT: 21px" type="text" size="8" value="1" name="Text2" runat="server">
其中,runat="server"是在设计器中右击选作为服务器控件运行。用来存放分辩率。
2、在客户端脚本中:
window.document.all.item("Text1").value=screen.width;
window.document.all.item("Text2").value=screen.height;
这样,分辨率就存放在控件中了。
注意:此脚本应放在aspx代码的底部,即</body>上端,否则在页面初始加载时因这两个控件还未生成,会报错。
3、在服务器端代码需要用到的地方:
string pagewidth=Request.Form["Text1"].ToString();
string pageheight=Request.Form['Text2"].ToString();
以上是COPY的,请问:
string pagewidth=Request.Form["Text1"].ToString();
string pageheight=Request.Form['Text2"].ToString();
是不是这样的:
<script type="text/javascript">
{
string pagewidth=Request.Form["Text1"].ToString();
string pageheight=Request.Form['Text2"].ToString();
}
</script>
我是这样,允许错误:
未将对象引用设置到对象的实例。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
{
string pagewidth=Request.Form["Text1"].ToString();
string pageheight=Request.Form['Text2"].ToString();
}
</script>
这个有错吗?