我认为这个表格有:
<!-- Bug (extra 'i') right here-----------v -->
<!-- was: <form method="post" enctype="mulitipart/form-data" action="/Task/SaveFile"> -->
<form method="post" enctype="multipart/form-data" action="/Task/SaveFile">
<input type="file" id="FileBlob" name="FileBlob"/>
<input type="submit" value="Save"/>
<input type="button" value="Cancel" onclick="window.location.href='/'" />
</form>
Run Code Online (Sandbox Code Playgroud)
这个代码在我的控制器中:
public ActionResult SaveFile( FormCollection forms )
{
bool errors = false;
//this field is never empty, it contains the selected filename
if ( string.IsNullOrEmpty( forms["FileBlob"] ) )
{
errors = true;
ModelState.AddModelError( "FileBlob", "Please upload a file" );
}
else
{
string sFileName = forms["FileBlob"];
var file …Run Code Online (Sandbox Code Playgroud) 如何以编程方式使控件的工具提示在Winforms应用程序中显示而无需鼠标悬停在控件上?(如果需要,可以使用P/Invoke).
我在c#中有一个Winforms应用程序,我希望TextBox在聚焦时自动更改语言.
我试过这段代码:
private void textBox1_Enter(object sender, EventArgs e)
{
SetKeyboardLayout(GetInputLanguageByName("fa"));
}
private void textBox1_Leave(object sender, EventArgs e)
{
SetKeyboardLayout(GetInputLanguageByName("eng"));
}
public static InputLanguage GetInputLanguageByName(string inputName)
{
foreach (InputLanguage lang in InputLanguage.InstalledInputLanguages)
{
if (lang.Culture.EnglishName.ToLower().StartsWith(inputName))
{
return lang;
}
}
return null;
}
private void SetKeyboardLayout(InputLanguage layout)
{
InputLanguage.CurrentInputLanguage = layout;
}
Run Code Online (Sandbox Code Playgroud)
但是当我输入textBox时,语言不会改变.我能做什么?
我的项目在同一解决方案文件中同时包含客户端和服务器组件.我通常将调试器设置为在调试时将它们一起启动,但通常情况下我在调试器外部启动服务器,因此我可以根据需要在客户端工作时启动和停止客户端.(这要快得多).
我正试图在解决方案资源管理器中解决问题,以便启动单个项目,而只是在工具栏上粘贴一个按钮,调用宏来启动单个项目的调试器(同时将"F5"类型的调试单独保留到启动两个进程).
我试过录音,但这并没有真正带来任何有用的东西.
到目前为止,我所要做的就是在解决方案资源管理器中找到项目项:
Dim projItem As UIHierarchyItem
projItem = DTE.ToolWindows.SolutionExplorer.GetItem("SolutionName\ProjectFolder\ProjectName").Select(vsUISelectionType.vsUISelectionTypeSelect)
Run Code Online (Sandbox Code Playgroud)
(这基于宏记录器如何尝试这样做.我不确定导航UI对象模型是否是正确的方法,或者我是否应该考虑通过解决方案/项目对象模型).
IronRuby和VS2010 noob问题:
我正试图做一个尖峰来测试C#项目和现有RubyGem之间的互操作的可行性,而不是重新发明.net中的特定轮.我已经下载并安装了IronRuby和RubyGems包,以及我最终想要使用的gem.
运行.rb文件或在iirb Ruby控制台中工作没有问题.我可以加载RubyGems包和gem本身并使用它,所以,至少对于那个用例,我的环境设置正确.
但是,当我尝试在C#(4.0)控制台应用程序中执行相同类型的操作时,它会抱怨第一行:
require 'RubyGems'
Run Code Online (Sandbox Code Playgroud)
有错误:
no such file to load -- rubygems
Run Code Online (Sandbox Code Playgroud)
我的控制台应用程序如下所示:
using System;
using IronRuby;
namespace RubyInteropSpike
{
class Program
{
static void Main(string[] args)
{
var runtime = Ruby.CreateRuntime();
var scope = runtime.ExecuteFile("test.rb");
Console.ReadKey();
}
}
}
Run Code Online (Sandbox Code Playgroud)
删除依赖项,只是做一些基本的自包含Ruby工作正常,但包括任何类型的'requires'语句似乎导致它失败.
我希望我只需要在创建它时将一些额外的信息(路径等)传递给ruby运行时,并且真的希望这不是某种限制,因为这会让我感到难过.