这个问题之所以存在,是因为它确实存在 具有历史意义,但事实并非如此 被认为是一个很好的主题问题 因为是本网站,所以请不要使用 作为证据,你可以问类似的问题 这里的问题。 更多信息:https://stackoverflow.com/faq
总有一些功能在边缘场景中很有用,但正是因为这个原因,大多数人都不知道它们。我要求的是课本上通常没有教过的特性。
你知道的是什么?
这个问题之所以存在,是因为它确实存在 具有历史意义,但事实并非如此 被认为是一个很好的主题问题 因为是本网站,所以请不要使用 作为证据,你可以问类似的问题 这里的问题。 更多信息:https://stackoverflow.com/faq
总有一些功能在边缘场景中很有用,但正是因为这个原因,大多数人都不知道它们。我要求的是课本上通常没有教过的特性。
你知道的是什么?
当前回答
Page指令中的MaintainScrollPositionOnPostback属性。它用于在回发时保持aspx页面的滚动位置。
其他回答
这是最好的一个。把它加到你的网里。配置更快的编译。这是3.5SP1后通过这个QFE。
<compilation optimizeCompilations="true">
Quick summary: we are introducing a new optimizeCompilations switch in ASP.NET that can greatly improve the compilation speed in some scenarios. There are some catches, so read on for more details. This switch is currently available as a QFE for 3.5SP1, and will be part of VS 2010. The ASP.NET compilation system takes a very conservative approach which causes it to wipe out any previous work that it has done any time a ‘top level’ file changes. ‘Top level’ files include anything in bin and App_Code, as well as global.asax. While this works fine for small apps, it becomes nearly unusable for very large apps. E.g. a customer was running into a case where it was taking 10 minutes to refresh a page after making any change to a ‘bin’ assembly. To ease the pain, we added an ‘optimized’ compilation mode which takes a much less conservative approach to recompilation.
通过在这里:
ScottGu在http://weblogs.asp.net/scottgu/archive/2006/04/03/441787.aspx上有一堆技巧
类似于optimizeCompilations= " true "的解决方案,这里有另一个可以加快你在构建之间等待的时间(非常好,特别是如果你正在处理一个大型项目):创建一个基于ram的驱动器(即使用RamDisk),并更改默认的“临时ASP。NET文件”到这个基于内存的驱动器。
关于如何做到这一点的完整细节在我的博客上:http://www.wagnerdanda.me/2009/11/speeding-up-build-times-in-asp-net-with-ramdisk/
基本上你首先配置一个RamDisk(同样,在我的博客中有一个免费RamDisk的链接),然后你改变你的网络。按此配置:
<system.web>
....
<compilation debug="true" tempDirectory="R:\ASP_NET_TempFiles\">
....
</compilation>
....
</system.web>
它大大增加了我的开发时间,你只需要为你的电脑投资内存:)
编程的快乐!
瓦格纳·丹达
WebMethods。
你可以使用ASP。NET AJAX回调到ASPX页面中的web方法。你可以用[WebMethod()]和[ScriptMethod()]属性来修饰一个静态方法。例如:
[System.Web.Services.WebMethod()]
[System.Web.Script.Services.ScriptMethod()]
public static List<string> GetFruitBeginingWith(string letter)
{
List<string> products = new List<string>()
{
"Apple", "Banana", "Blackberry", "Blueberries", "Orange", "Mango", "Melon", "Peach"
};
return products.Where(p => p.StartsWith(letter)).ToList();
}
现在,在你的ASPX页面你可以这样做:
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
<input type="button" value="Get Fruit" onclick="GetFruit('B')" />
</div>
</form>
并通过JavaScript调用您的服务器端方法使用:
<script type="text/javascript">
function GetFruit(l)
{
PageMethods.GetFruitBeginingWith(l, OnGetFruitComplete);
}
function OnGetFruitComplete(result)
{
alert("You got fruit: " + result);
}
</script>
默认情况下,自定义控件的标记之间的任何内容都被添加为子控件。这可以在AddParsedSubObject()覆盖中截获,用于过滤或额外的解析(例如,LiteralControls中的文本内容):
protected override void AddParsedSubObject(object obj)
{ var literal = obj as LiteralControl;
if (literal != null) Controls.Add(parseControl(literal.Text));
else base.AddParsedSubObject(obj);
}
...
<uc:MyControl runat='server'>
...this text is parsed as a LiteralControl...
</uc:MyControl>