我收到以下错误:"解析服务此请求所需的资源时出错.请查看以下特定的解析错误详细信息并适当修改源文件."
Parser Error Message: `Could not load type 'nadeem.MvcApplication'`.
Source Error: Line 1: <%@ Application Codebehind="Global.asax.cs" Inherits="nadeem.MvcApplication" Language="C#" %>
Run Code Online (Sandbox Code Playgroud) 我无法理解我的错误
方法:
public List<Task> GetAllTasks()
{
var AllTasks = from t in tasks
where t.Status.ToString() == "Completed" || t.Status.ToString() == "Pending"
select t;
return (List<Task>)AllTasks;
}
Run Code Online (Sandbox Code Playgroud)
代码背后:
protected void Page_Load(object sender, EventArgs e)
{
TaskList tdl = (TaskList)Session["TodoList"];
List<Task> AllTasks = tdl.GetAllTasks();
string str = "";
foreach (Task t in AllTasks)
{
str += t.ToString() + "<br />";
}
LblTasks.Text = str;
}
Run Code Online (Sandbox Code Playgroud)
添加任务(AddTask.aspx)后,我重定向到另一个页面以显示它们,然后我得到运行时错误:
无法转换'WhereListIterator 1[Task]' to type 'System.Collections.Generic.List1 [Task]' 类型的对象.
我的LINQ有问题吗?我刚学会了嘿嘿.
谢谢.
当Image的Source属性按以下方式设置时,图片取自/Images/down.png.
我如何以编程方式执行相同的操作?
<Image x:Name="myImg" Source="/MyProject;component/Images/down.png" />
Run Code Online (Sandbox Code Playgroud)
以下操作无效,因为Image.Source属性不是字符串类型.
myImg.Source = "/MyProject;component/Images/down.png";
Run Code Online (Sandbox Code Playgroud) 如何span从代码后面添加标签?有没有等效的HtmlControl?我目前正在这样做.我正在构建Itemplate实现中的表行.
var headerCell = new TableHeaderCell { Width = Unit.Percentage(16)};
var span = new LiteralControl("<span class='nonExpense'>From<br/>Date</span>");
headerCell.Controls.Add(span);
headerRow.Cells.Add(headerCell);
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用new Label(),但我试图在这里避免服务器控制.我是否正确使用LiteralControl这种方式?有没有人对如何做到这一点有更好的想法?
这可能是一个愚蠢的问题,但我怎么设置的字体TextBox从string后面的代码?
// example
txtEditor.FontFamily = "Consolas";
Run Code Online (Sandbox Code Playgroud) 我有几个GUI控件元素,其中一些应该在鼠标交互(MouseEnter,MouseLeave)上生成相同的操作(代码隐藏函数调用).
[edit] 我在我的事件处理程序中执行一些非样式相关的功能.
现在我在每个控件中使用事件属性:
<Button Name="Button" Content="Button 1"
MouseEnter="GeneralMouseEnter" MouseLeave="GeneralMouseLeave"
PreviewMouseDown="Button1_PreviewMouseDown" PreviewMouseUp="Button1_PreviewMouseUp" />
<Button Name="NotInteractingButton" Content="Button 2"
/><!-- this button has no MouseOver-effects -->
<ToggleButton Content="ToggleButton"
MouseEnter="GeneralMouseEnter" MouseLeave="GeneralMouseLeave" />
<!-- needs to use IsMouseDirectlyOver on the slider knob... -->
<Slider Name="HorizontalSlider"
MouseEnter="GeneralMouseEnter" MouseLeave="GeneralMouseLeave"
ValueChanged="Slider_ValueChanged" />
<Slider Name="VerticalSlider" Orientation="Vertical"
MouseEnter="GeneralMouseEnter" MouseLeave="GeneralMouseLeave"
ValueChanged="Slider_ValueChanged" />
Run Code Online (Sandbox Code Playgroud)
由于此示例中的许多控件都调用相同的两个函数"GeneralMouseEnter"和"GeneralMouseLeave",因此我希望能够定义一个样式或类似的东西来封装该行为.
[编辑 - 澄清]
这应该成为后来的一种插件.
(将代码和XAML文件包含到任何GUI程序中,并在每个交互式控件元素上设置样式...)
根据我在网络上发现的内容,我可以EventTriggers在此示例中使用:
<Style.Triggers>
<EventTrigger RoutedEvent="Click">
<EventTrigger.Actions>
<BeginAction TargetName="SomeAction" />
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
Run Code Online (Sandbox Code Playgroud)
我不知道是否以及如何在一个动作中调用函数.
有谁知道如何在代码背后创建一个wpf样式,我在网络或MSDN文档上找不到任何东西.我试过这个,但它不起作用:
Style s = new Style(typeof(TextBlock));
s.RegisterName("Foreground", Brushes.Green);
s.RegisterName("Text", "Green");
breakInfoControl.dataTextBlock.Style = s;
Run Code Online (Sandbox Code Playgroud) 在asp.net的Windows窗体应用程序中,在C#代码后面你可以使用:
MessageBox.Show("Here is my message");
Run Code Online (Sandbox Code Playgroud)
在asp.net Web应用程序中是否有任何等价物?我可以从后面的C#代码中调用一些可以向用户显示消息框的内容吗?
示例用法:我有一个按钮,可以在后面的代码中加载文件.加载文件或出现错误时,我想向用户弹出一条消息,说明结果.
有什么想法吗?
很简单的问题,但似乎无法在这里找到完整的答案......
我需要在xaml中将数据绑定到codebehind中的类成员的属性.
<Window x:Class="Main">
<customcontrol Name="View" IsChecked="{Binding ElementName=RecordProp, Path=IsViewChecked}" />
...
Run Code Online (Sandbox Code Playgroud)
背后的代码如下所示:
class Main
{
...
private Record _record;
public Record RecordProp
{
get { return _record; }
}
...
}
class Record
{
public bool IsViewChecked
{
get; set;
}
}
Run Code Online (Sandbox Code Playgroud)
我现在得到的东西不起作用,我做错了什么?
我有~30个SpecFlow功能文件,我最近从源代码控制中删除了Foo.feature.cs文件,因为我厌倦了解决Designer Generated代码中的合并冲突.
我没有从Visual Studio项目中排除或删除这些文件,因此Visual Studio仍然认为它们应该在那里,它们只是在硬盘上丢失了.
理想情况下,我只想单击一个根文件夹并重新生成文件后面的所有代码,但VS 2010和SpecFlow 1.9不存在这样的选项.我甚至可以通过编程从命令行重新生成它们,创建另一个自定义工具或添加预编译构建事件.
有没有办法为SpecFlow功能(*.feature.cs文件)重新生成所有Designer生成的代码,而无需右键单击每个.feature文件并单击"运行自定义工具"?
code-behind ×10
c# ×7
wpf ×4
asp.net ×3
styles ×2
.net ×1
bdd ×1
customtool ×1
data-binding ×1
events ×1
html ×1
image ×1
linq ×1
messagebox ×1
silverlight ×1
specflow ×1