当我使用Html.DisplayFor()使用模型的属性时,它很好地与属性名称的标签和具有属性值的文本框或标签:
Html.DisplayFor(model => model.FirstName) // renders as First Name: Joe Smith
Run Code Online (Sandbox Code Playgroud)
但是如果我尝试在ViewData中使用相同的东西,它似乎没有任何方法来指定将在渲染的html中的标签中使用的文本:
Html.Display(ViewData["something"].ToString()) // renders as (no label) something
Run Code Online (Sandbox Code Playgroud)
其他Html.Display()参数看起来没有帮助:
Html.Display(ViewData["something"].ToString(), "TemplateName", "HtmlElementId", {additionalData})
Run Code Online (Sandbox Code Playgroud)
看起来我可能传递标签的唯一地方是使用additionalData参数,但我没有找到任何关于如何执行此操作的示例或文档.
SQL Server(2010)中是否有一种简单的方法来执行存储过程(返回表)并在一个(或几个)语句中对一列求和?
例如
SELECT SUM(column) FROM exec proc_GetSomeStuff 'param1', 'param2'
Run Code Online (Sandbox Code Playgroud) 我使用的是WindowsPhone Toolkit的ExpanderView,在第一次加载时,扩展的Expander总是看起来像第二张图片.看起来,它始终处于所有物品的同一高度.
如果我转到另一页并返回,一切都会很好,布局看起来很安静 - 除了停止扩展器的行(图1).
this.UpdatedLayout();(当前页面)或ExpanderView.UpdateLayout(); 解决了什么.未显示的项目已在该列表中完全加载.


<ItemsControl ItemsSource="{Binding EpisodeList}" Margin="20,0,0,0" Grid.Row="1" Grid.ColumnSpan="2">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel>
<toolkit:ExpanderView ItemsSource="{Binding Value}" >
<toolkit:ExpanderView.Header>
<TextBlock Margin="0,0,10,0">
<Run Text="Season "/>
<Run Text="{Binding Key}" />
</TextBlock>
</toolkit:ExpanderView.Header>
<toolkit:ExpanderView.ItemTemplate>
<DataTemplate>
<Border BorderBrush="White" BorderThickness="1" Margin="5">
<Grid MouseLeftButtonUp="Grid_MouseLeftButtonUp">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Image Height="40" Source="{Binding ScreenCap}" Margin="5,0,0,0"/>
<TextBlock x:Name="t" Margin="10" Text="{Binding Title}" TextWrapping="Wrap" Grid.Column="1" />
</Grid>
</Border>
</DataTemplate>
</toolkit:ExpanderView.ItemTemplate>
</toolkit:ExpanderView>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
Run Code Online (Sandbox Code Playgroud)
EpisodeList是Dictionary(int,ObservableCollection(myClass))的类型,并实现了INotifyPropertyChanged
如果有人有任何计划在这里出错,我真的很感激你的帮助,我只是没有在谷歌上找到任何bug报告,也没有类似的Bug.
(在设备和仿真器上调试)
我正在尝试学习如何在MVC2中使用AsyncController,但是那里的文档/教程很少.我正在寻找一种普通的控制器方法,它对第三方服务的导出非常慢,并将其转换为异步方法.
原始控制器方法:
public JsonResult SaveSalesInvoice(SalesInvoice invoice)
{
SaveInvoiceToDatabase(invoice); // this is very quick
ExportTo3rdParty(invoice); // this is very slow and should be async
}
Run Code Online (Sandbox Code Playgroud)
所以我创建了一个继承自AsyncController的新控制器:
public class BackgroundController : AsyncController
{
public void ExportAysnc(int id)
{
SalesInvoice invoice = _salesService.GetById(id);
ExportTo3rdParty(invoice);
}
public void ExportCompleted(int id)
{
// I dont care about the return value right now,
// because the ExportTo3rdParty() method
// logs the result to a table
}
public void Hello(int id)
{
}
}
Run Code Online (Sandbox Code Playgroud)
然后从jQuery调用Export方法:
function Export() …Run Code Online (Sandbox Code Playgroud) 我正在尝试将此方法转换ExportTo3rdParty()为使用AsyncController:
public JsonResult SaveSalesInvoice(SalesInvoice invoice)
{
SaveInvoiceToDatabase(invoice); // this is very quick
ExportTo3rdParty(invoice); // this is very slow and should be async
}
Run Code Online (Sandbox Code Playgroud)
但是ExportTo3rdParty()方法在多个地方使用HttpContext.Current(太多不能改变 - 原始编码器没有使用足够的依赖注入).例如,它调用GetDefaultCurrency().当通过AsyncController调用ExportTo3rdParty()时,这仍然有用吗?
public Currency GetDefaultCurrency()
{
Currency currency;
string key = string.Format("DefaultCurrency_{0}",
HttpContext.Current.User.Identity.Name);
currency = HttpRuntime.Cache.Get(key) as Currency;
if (currency == null)
{
currency = LookupDefaultCurrency();
HttpRuntime.Cache[key] = currency;
}
}
Run Code Online (Sandbox Code Playgroud)
我知道如果我使用Thread.Start,我无法访问HttpContext.Current.但是AsyncController怎么样?
我安装了VS 2010终极版.它没有MVC3.我安装了SP1,它应该已经安装了更新以及MVC3 - 对吧?
但是在安装之后,我仍然没有新项目窗口中的MVC3选项.这有什么不对?
我有一个div容器,当我点击一个Add按钮时,我正在创建一个动态文本框控件
<div id="Container">
<input type="Submit" id="AddTextBox" value="Add">
<!-- Here are my dynamic textboxes -->
<input type="text" value='' class="dynamic">
<input type="text" value='' class="dynamic">
<input type="text" value='' class="dynamic">
</div>
<input type="create" id="create" onclick="GetValue();" value="create">
Run Code Online (Sandbox Code Playgroud)
我想获得所有文本框控件的值,例如:
Function GetValue()
{
var COntain=TextBoxValue+"$"+Textbox2Value+"$"; // so on
}
Run Code Online (Sandbox Code Playgroud) 你如何在jQuery中编写新的链式方法?我的jQuery中有一个非常程序化的风格:
$("#SaveButton").click(function () {
Foo($("#SubTotal"));
Foo($("#TaxTotal"));
Foo($("#Total"));
Bar($("#SubTotal"));
Bar($("#TaxTotal"));
Bar($("#Total"));
});
Run Code Online (Sandbox Code Playgroud)
如何在jQuery中创建一个.foo()方法,以便我可以编写:
$("#SaveButton").click(function () {
$("#SubTotal,#TaxTotal,#Total").foo().bar();
});
Run Code Online (Sandbox Code Playgroud)
并在相关点-是否有一种简单的方法(在Visual Studio或记事本++或别的东西)来查找和替换所有Foo($("#selector"));用$("#selector").foo();?
我有一个问题,如果不应该将子对象添加到父对象异常缓慢.有成千上万个子对象(在这种情况下为33k记录),但这些对象都不是父对象的子对象.
当我将第一个孩子添加到父母时,需要一分钟以上才能完成:
public class ParentEntity // POCO generated by EF TT4 templates
{
public virtual int Id { get; set; }
public virtual ICollection<ChildEntity> ChildEntities {}
}
public class ChildEntity // POCO generated by EF TT4 templates
{
public virtual int Id { get; set; }
public virtual int ParentEntityId { get; set; }
public virtual ParentEntity ParentEntity { get; set; }
public virtual Warehouse Warehouse { get; set; }
public virtual WarehouseLocation WarehouseLocation { get; set; }
}
public …Run Code Online (Sandbox Code Playgroud) 我们对某些Internet Explorer版本有一些奇怪的问题,所以我们有一个浏览器开关
<head>
<!--[if IE 6]>
<!-- load some IE6 stuff -->
<meta http-equiv="X-UA-Compatible" content="IE=6" />
<![endif]-->
<!--[if IE 7]>
<!-- load some IE7 stuff -->
<meta http-equiv="X-UA-Compatible" content="IE=6" />
<![endif]-->
<!--[if IE 8]>
<!-- load some IE8 stuff -->
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<![endif]-->
<!--[if IE 9]>
<!-- load some IE9 stuff -->
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<![endif]-->
</head>
Run Code Online (Sandbox Code Playgroud)
如果我像这样加载它,我在IE9 Developer附加组件中看到:
HTML1115:与X-UA兼容的META-Tag("IE = 8")被忽略,因为documentmodus已经加载.
(最初是德语,所以我应该翻译)
并且文档模式仍然是IE9
如果我在我的<head>标签中写得很难:
<meta http-equiv="X-UA-Compatible" content="IE=8" />
Run Code Online (Sandbox Code Playgroud)
IE9将作为IE8加载,所以这可行,但那时IE6的东西当然是错误的....
那么有没有办法像我第一次尝试那样做?
internet-explorer browser-detection internet-explorer-9 x-ua-compatible
jquery ×4
c# ×3
asp.net-mvc ×2
exec ×1
expander ×1
performance ×1
select ×1
sql ×1
sql-server ×1