49.Customizing codeplex frozen header gridview
48.运行时错误
1.打开Asp.Net State Service
2.参考以下Page http://www.shanrui.net/bbs/showtopic-1335.aspx
http://tech.0532163.com/news/65/200881919445.htm
“/AirHotelService”应用程序中的服务器错误。
运行时错误
说明: 服务器上出现应用程序错误。此应用程序的当前自定义错误设置禁止远程查看应用程序错误的详细信息(出于安全原因)。但可以通过在本地服务器计算机上运行的浏览器查看。
详细信息: 若要使他人能够在远程计算机上查看此特定错误信息的详细信息,请在位于当前 Web 应用程序根目录下的“web.config”配置文件中创建一个 <customErrors> 标记。然后应将此 <customErrors> 标记的“mode”属性设置为“Off”。
<!-- Web.Config 配置文件 -->
<configuration>
<system.web>
<customErrors mode="Off"/>
</system.web>
</configuration>
注释: 通过修改应用程序的 <customErrors> 配置标记的“defaultRedirect”属性,使之指向自定义错误页的 URL,可以用自定义错误页替换所看到的当前错误页。
<!-- Web.Config 配置文件 -->
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
</system.web>
</configuration>
47.利用UrlRewrite,asp.net动态生成htm页面 http://www.cnblogs.com/fengfeng/archive/200801301058890.html
46.在GridView中如果使用Row_Updating事件时,如果你设置了此GridView的EnabledViewStatus = false时,Row_updating事件是不会有响应的。必须开启。
45.在Dictionary中使用枚举
http://www.agiledon.com/post/Coding/Enum-in-Dictionary.html
44.ASP.NET Popup Control
http://www.codeproject.com/KB/custom-controls/asppopup.aspx
43.Outlook 2003 Style Navigation Pane
http://www.codeproject.com/KB/office/Outlook_Navigation_Pane.aspx
42.List<T> Sort
http://www.dotblogs.com.tw/chhuang/archive/2008/05/08/3908.aspx
41.GroupedGridview - A Customized GridView Control
http://www.codeproject.com/KB/webforms/Grouped_Gridview.aspx
http://www.agrinei.com/gridviewhelper/gridviewhelper_en.htm
http://www.microsoft.com/taiwan/msdn/columns/huang_jhong_cheng/ASP_NET_GridView.htm
40.Editing Cell GridView and Update Data
http://www.codeproject.com/KB/webforms/EditGridviewCells.aspx
39.Single & Double Click Rows with GridView, DataList and ListBox
http://www.codeproject.com/KB/webforms/DoubleClickGridviewRow.aspx
38.EnterpriseLibrary应用出错的解决办法
System.Web.Services.Protocols.SoapException: 服务器无法处理请求。 ---> System.IO.FileLoadException: 未能加载文件或程序集“Microsoft.Practices.EnterpriseLibrary.Common, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null”或它的某一个依赖项。找到的程序集清单定义与程序集引用不匹配。 (异常来自 HRESULT:0x80131040)
37.取最新时间
--创建表
CREATE TABLE dbo.Tab
(
ID int NOT NULL IDENTITY (1, 1),
Y varchar(20) NOT NULL,
X datetime NOT NULL
)
select max(ID) as id,b.Y,max(b.X)
from (
select Y,MAX(x) AS X
from Tab
group by Y) b
join Tab a on a.Y=b.Y and a.X=b.X
group by b.Y
GO
--插入数据
INSERT INTO Tab(Y, X) values('BBB', '2007-10-23 11:11:11')
INSERT INTO Tab(Y, X) values('BBB', '2007-10-23 11:11:11')
INSERT INTO Tab(Y, X) values('BBB', '2007-10-23 10:10:10')
INSERT INTO Tab(Y, X) values('AAA', '2007-10-23 12:12:12')
INSERT INTO Tab(Y, X) values('AAA', '2007-10-23 10:10:10')
INSERT INTO Tab(Y, X) values('AAA', '2007-10-23 11:11:11')
select ID,Y,X
from Tab t
where (not exists
(select 1
from Tab t2
where (t2.Y = t.Y) and
(t2.X > t.X or t2.X = t.X and t2.ID >t.ID)
)
)
select Y,max(X) as X
from Tab
group by y
36.Silverlight跨域,Silverlight在IIS中部署
http://www.cnblogs.com/seeker/archive/2009/01/22/1379732.html
35.根据xsd生成xml文档
http://www.cnblogs.com/eric812/archive/2006/11/01/546914.html
34.如何通过Javascript读取不在同一个服务器上的网页(js跨域)
跨域读取确实存在权限问题,单纯靠JS解决不掉,你可以做个JS代理
就是在你服务器上放一个页面用于读取另一个服务器的网页,JS改请求自己服务器上的这个页面,这个页面的功能相当于一个代理,协助JS从其他服务器读取文件
当然也可以让这个页面接收参数,这样可以实现在客户端通过JS读取任意网页
http://space.cnblogs.com/question/3427/
33.正则表达式验证日期和时间
---你输入的时间是不是正确,并能验证闰年
public bool ValidateTime(string str) {
bool flag=false;
string regex = @"^(("d{2}(([02468][048])|([13579][26]))["-"/"s]?((((0?[13578]
)|(1[02]))["-"/"s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[4
69])|(11))["-"/"s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2["-"/"
s]?((0?[1-9])|([1-2][0-9])))))|("d{2}(([02468][1235679])|([1
3579][01345789]))["-"/"s]?((((0?[13578])|(1[02]))["-"/"s]?((
0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))["-"/"s]?((
0?[1-9])|([1-2][0-9])|(30)))|(0?2["-"/"s]?((0?[1-9])|(1[0-9]
)|(2[0-8]))))))"; //日期部分
regex += @"("s(((0?[0-9])|([1-2][0-3]))":([0-5]?[0-9])(("s)|(":([0-5]?[0-9])))))?$"; //时间部分
RegexOptions options = ((RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline) | RegexOptions.IgnoreCase);
Regex reg = new Regex(regex, options);
if(reg.IsMatch(str)) {
flag=true;
}
return flag;
}
32.Cross-Page PostBack
症状:A页面有一个asp:HyperLink,通过它跳转到B页面时,B页面会page_load两次,导致无法正常
解决:
var elm = document.aspnetForm.elements["__EVENTTARGET"];
elm.parentNode.removeChild(elm);
elm = document.aspnetForm.elements["__EVENTARGUMENT"];
elm.parentNode.removeChild(elm);
完整代码:
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
页面代码:
<asp:HyperLink ID="hlCorpSearch" runat="server" Text=" Search Price Of Corp Hotel"
Visible="false"></asp:HyperLink>
脚本代码:
<input type="hidden" name="hotel" />
<input type="hidden" name="arrival" />
<input type="hidden" name="departure" />
<input type="hidden" name="room" />
<input type="hidden" name="city" />
<input type="hidden" name="payType" />
<input type="hidden" name="startdate" />
<input type="hidden" name="depdate" />
<input type="hidden" name="operationType" />
<script language="javascript" type="text/javascript">
function searchCorpHotel(url,hotelID,startdate,depdate,operationType)
{
var elm = document.aspnetForm.elements["__EVENTTARGET"];
elm.parentNode.removeChild(elm);
elm = document.aspnetForm.elements["__EVENTARGUMENT"];
elm.parentNode.removeChild(elm);
//action url
document.aspnetForm.action = url;
//transfer Paramerters
document.aspnetForm.hotel.value = hotelID;
document.aspnetForm.startdate.value = startdate;
document.aspnetForm.depdate.value = depdate;
document.aspnetForm.operationType.value = operationType;
document.aspnetForm.__VIEWSTATE.name = 'NOVIEWSTATE';
document.aspnetForm.submit();
}
</script>
Code:
hlCorpSearch.NavigateUrl = String.Format( Settings.Default.jsClickSearch ,
url ,
hotelID ,
CorpHotelInput.ArrivalDate.ToString( "yyyy-MM-dd" ) ,
CorpHotelInput.DepartureDate.ToString( "yyyy-MM-dd" ),
operationType );
参考资料:
![ContractedBlock.gif](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
ASP Dot Net cross-page postback blues
The more I work with ASP.Net, the more convinced I become that it is nothing more than a sophisticated version of MS FrontPage. Jeepers it’s horrible! And in it’s attempts to make like easy for developers (Microsoft’s way of locking the insecure into their products), it produces probably the biggest mess I’ve ever seen. ASP.Net developers seem unable to live without posting back to the server every few seconds, with their favorite trick being a postback with a Response.Redirect… Yuk! Yuk! YUK!!
If you’re like me and want to post directly to the page that should receive the data, here is a nice and easy way of working around Microsoft’s stupid security rubbish and their pathetic attempts at maintaining state. In your JavaScript code on the client side, run this: -
var elm = document.aspnetForm.elements[”__EVENTTARGET”];
elm.parentNode.removeChild(elm);
elm = document.aspnetForm.elements[”__EVENTARGUMENT”];
elm.parentNode.removeChild(elm);
elm = document.aspnetForm.elements[”__VIEWSTATE”];
elm.parentNode.removeChild(elm);
document.aspnetForm.action=”Put the url of the target page here”;
document.aspnetForm.submit();
And hey presto! You’ve escaped the dreaded ASP.Net cross-page postback blues.
IsPostBack深入探讨 :http://www.cnblogs.com/hobe/archive/2008/04/06/1139031.html
31.怎么取一个表记录中的第N~M条记录 (6种方法)
select top 20 * from ProductDB.dbo.sellhotellist
except
select top 10 * from ProductDB.dbo.sellhotellist
-- Nest Search
select * from
( select top 10 * from
( select top 20 *
from ProductDB.dbo.sellhotellist
order by HotelID) t1
order by HotelID desc ) t2
order by HotelID
-- Max & Order By
select top 10 *
from ProductDB.dbo.sellhotellist
where HotelID > ( select max (HotelID)
from ( select top 10 HotelID
from ProductDB.dbo.sellhotellist
order by HotelID) t1)
order by HotelID
-- Not in & Order By
select top 10 *
from ProductDB.dbo.sellhotellist
where HotelID not in ( select top 10 HotelID
from ProductDB.dbo.sellhotellist
order by HotelID)
order by HotelID
-- Not in
select top 20 *
from ProductDB.dbo.sellhotellist
where HotelID not in ( select top 11 HotelID
from ProductDB.dbo.sellhotellist )
-- 临时表 & B
select identity ( int , 1 , 1 ) as rowCounts, * into # temp from ProductDB.dbo.sellhotellist
select * from # temp where rowCounts between 11 and 20