测试我的webforms应用程序的最佳方法是什么?
看起来人们喜欢Watin和硒.
我正在看一个ASP.NET应用程序,它大量使用meta:resourcekey,它似乎连接到resx文件.
这是一个看起来完全超越我的领域.有没有人对这种方法的好处和目的以及最佳实践有任何指导?
考虑一种情况,您想要检索一个List或IEnumerable多个所选复选框的值<asp:CheckBoxList>.
这是当前的实现:
IEnumerable<int> allChecked = (from item in chkBoxList.Items.Cast<ListItem>()
where item.Selected
select int.Parse(item.Value));
Run Code Online (Sandbox Code Playgroud)
问题:如何使用lambda表达式或lambda语法改进此LINQ查询?
关于ASP.NET 4.5的新System.Web.Optimization/Microsoft.AspNet.Web.Optimization:
任何人都可以解释使用BundleConfig.cs类文件而不是bundle.config xml文件使用捆绑资源的区别吗?
我看过一些文章显示在BundleConfig.cs中捆绑了js和css,而其他文章则显示BundleConfig.cs中的捆绑js和bundle.config中的css.
我想我不明白#1)为什么你不会为了简单而以一种特殊的方式做到这一点 - 以及#2)为什么有人宁愿在类文件中对这些资源进行硬编码呢?将它们放在一个xml文件中似乎是一种更加动态的方法,可以在必要时即时更改.
似乎更多的文章实际上倾向于使用BundleConfig.cs而不是其他任何东西.是否有某些特定的赞成或赞成鼓励这一点?
另外,如果有关于System.Web.Optimization的任何真实文档,我很想知道位置(因为我肯定找不到它).
谢谢-
我有一个DropDownList内部版本UpdatePanel,填充在回发中SqlDataSource.它有一个参数是另一个控件.我有时需要多个回发,但是每次更新面板刷新时都会发生这样的事情DropDownList.因此DropDownList最终会产生不正确的数据或重复的数据.
我将AppendDataBoundItems属性设置为,true因为我需要第一个项目为空白.
我怎样才能克服这个问题?还有另一种方法可以让第一个项目空白吗?
(这DropDownList是在asp.net-2.0网络应用程序中,代码隐藏在c#中)
谢谢.
我认为这是纯HTML:
<label for="txtPais">Pais:</label>
<input name="ctl00$ContentPlaceHolder1$txtPais" type="text" id="ctl00_ContentPlaceHolder1_txtPais" class="textInput" />
Run Code Online (Sandbox Code Playgroud)
在我在Visual Studio中的实际代码中,我有这样的:
<label for="txtPais">Pais:</label>
<asp:TextBox ID="txtPais" runat="server" CssClass="textInput"></asp:TextBox>
Run Code Online (Sandbox Code Playgroud)
如何为此文本框应用标签?
背景:使用VB.NET后端的ASP.NET Webforms应用程序.
我刚刚从Visual Studio 2010升级到Visual Studio 2013和.NET 4.5.1.此代码以前用于Visual Studio 2005和.NET 2.0.但自从升级后我得到了这个错误.
在ASCX用户控件中.
<script language="javascript" type="text/javascript">
<!--
function SetItem_<%Response.Write(m_strJSAlias)%>(strValue) {
$("#<%Response.Write(txtShop.ClientID)%>").attr('value',strValue);
__doPostBack('frmCorpPortal_Form','');
void FocusOnNext_<%response.Write(m_strJSAlias)%>;
}
Run Code Online (Sandbox Code Playgroud)
我们现在得到了以前从未得到过的错误:
VirtualPath was outside the current application root.
Parameter name: virtualPath
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: VirtualPath was outside the current application root.
Parameter name: virtualPath
Line …Run Code Online (Sandbox Code Playgroud) 在ASP.NET站点中使用会话时,几乎在同一时间加载多个请求时会导致严重的延迟(500毫秒的倍数).
我们的网站专门为其SessionId使用会话.我们使用此密钥来查找具有用户信息等的db表.这似乎是一个很好的设计,因为它存储了最少的会话数据.不幸的是,如果你在会话中没有任何东西,SessionId会改变,所以我们存储Session["KeepId"] = 1;.这足以说服SessionId不要改变.
在一个看似无关的说明中,该网站通过控制器操作提供定制的产品图像.如果需要,此操作会生成图像,然后重定向到缓存的图像.这意味着一个网页可能包含图像或其他资源,通过ASP.NET管道发送数十个请求.
无论出于何种原因,当您(a)同时发送多个请求并且(b)以任何方式涉及会话时,您将最终获得大约1/2时间的随机500ms延迟.在某些情况下,这些延迟将是1000毫秒或更长,总是以~500毫秒的间隔增加.更多请求意味着更长的等待时间 对于某些图像,我们包含数十张图像的页面可能需要等待10秒以上.
创建一个空的控制器动作:
public class HomeController : Controller
{
public ActionResult Test()
{
return new EmptyResult();
}
}
Run Code Online (Sandbox Code Playgroud)创建一个test.html页面,其中包含一些符合该操作的img标记:
<img src="Home/Test?1" />
<img src="Home/Test?2" />
<img src="Home/Test?3" />
<img src="Home/Test?4" />
Run Code Online (Sandbox Code Playgroud)运行页面并观察firebug中的快速加载时间:

执行以下操作之一(两者都具有相同的结果):
向Global.asax.cs添加一个空的Session_Start处理程序
public void Session_Start() { }
Run Code Online (Sandbox Code Playgroud)把东西放在会议中
public class HomeController : Controller
{
public ActionResult Test()
{
HttpContext.Current.Session["Test"] = 1;
return new EmptyResult();
}
}
Run Code Online (Sandbox Code Playgroud)再次运行该页面并注意响应中的偶然/随机延迟.

如何对按钮进行编码,以便在单击按钮时将其带到另一个Web表单?假设按钮名称为Confirm,结婚格式为confirm.aspx?
protected void btnConfirm_Click(object sender, EventArgs e)
{
(guessing that there should be an input here)
}
Run Code Online (Sandbox Code Playgroud) 我在Global.asax中定义了几条路线;
当我在页面上时,我需要弄清楚当前路由的路由名称是什么,因为路由名称驱动我的站点菜单.
如何才能做到这一点?
webforms ×10
asp.net ×9
c# ×2
append ×1
asp.net-4.5 ×1
asp.net-mvc ×1
browser-link ×1
button ×1
httpsession ×1
label ×1
linq ×1
routing ×1
session ×1
url-routing ×1