使用window.open方法我打开带有参数的新站点,我必须通过post方法传递.我找到了解决方案,但不幸的是它不起作用.这是我的代码:
<script type="text/javascript">
function openWindowWithPost(url,name,keys,values)
{
var newWindow = window.open(url, name);
if (!newWindow) return false;
var html = "";
html += "<html><head></head><body><form id='formid' method='post' action='" + url +"'>";
if (keys && values && (keys.length == values.length))
for (var i=0; i < keys.length; i++)
html += "<input type='hidden' name='" + keys[i] + "' value='" + values[i] + "'/>";
html += "</form><script type='text/javascript'>document.getElementById(\"formid\").submit()</sc"+"ript></body></html>";
newWindow.document.write(html);
return newWindow;
}
</script>
Run Code Online (Sandbox Code Playgroud)
接下来,我创建数组:
<script type="text/javascript">
var values= new Array("value1", "value2", "value3")
var keys= new Array("a","b","c")
</script> …Run Code Online (Sandbox Code Playgroud) 如何比较此枚举的值
public enum AccountType
{
Retailer = 1,
Customer = 2,
Manager = 3,
Employee = 4
}
Run Code Online (Sandbox Code Playgroud)
我试图在MVC4控制器中比较这个枚举的值,如下所示:
if (userProfile.AccountType.ToString() == "Retailer")
{
return RedirectToAction("Create", "Retailer");
}
return RedirectToAction("Index", "Home");
Run Code Online (Sandbox Code Playgroud)
我也尝试过这个
if (userProfile.AccountType.Equals(1))
{
return RedirectToAction("Create", "Retailer");
}
return RedirectToAction("Index", "Home");
Run Code Online (Sandbox Code Playgroud)
在每种情况下,我都得到一个未设置为对象实例的Object引用.
我有一个叫做接受的课Test,另一个接受.请参阅以下代码段.constructorAction<T>Func<T,T>
public class Test<T>
{
//constructors
public Test() { }
public Test(Action<T> action) { }
public Test(Func<T, T> action) { }
//methods with same signature of constructor
public void MyMethod1(Action<T> action) { }
public void MyMethod2(Func<T, T> action) { }
}
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Test<string> t1 = new Test<string>(this.MyMethod1);
Test<string> t2 = new Test<string>(this.MyMethod2);
Test<string> t = new Test<string>();
t.MyMethod1(MyMethod1);
t.MyMethod2(MyMethod2);
}
public void MyMethod1(string value) { …Run Code Online (Sandbox Code Playgroud) 我已经看到了一些如何使用C#检查URL中是否存在查询字符串的示例:
www.site.com/index?query=yes
if(Request.QueryString["query"]=="yes")
Run Code Online (Sandbox Code Playgroud)
但是如何在没有参数的情况下检查字符串呢?我只需要看看它是否存在.
www.site.com/index?query
if(Request.QueryString["query"] != null) //why is this always null?
Run Code Online (Sandbox Code Playgroud)
我知道可能有一个简单的答案,我会觉得愚蠢,但我还没有找到它.谢谢!
我运行Windows 7 32位,我安装了IIS,Visual Studio 2008,2010.我厌倦了SQL Server 2008中的这个错误,它是:
Windows无法在本地计算机上启动SQL Server(SQLEXPRESS)服务.错误1053:服务未及时响应启动或控制请求
我用谷歌搜索并访问了许多其他网站.
我试过以下:
我无法检查日志文件,因为它不存在于MS SQL文件夹的LOG文件夹中.我已经修改了有关此问题的修订文章的注册表信息,但这些网站没有运气.
这真的很烦人,因为我之前安装了SQL Server 2005 Express并得到了相同的错误消息,这就是为什么我卸载了这个并决定给SQL Server 2008 Express一个去,我收到同样的错误.
这真的让我失望,因为我在我的网站上开发了很多网页,现在我想为网站添加功能,我需要SQL Server,这确实阻止了我的工作.
有人可以帮忙吗?我真的需要解决这个问题,我已经尝试了网站在Google中提供的所有功能.如果您需要更多信息,我们很乐意为您提供反馈,以便尽快解决问题.
sql database sql-server sql-server-express sql-server-2008-r2
这就是我在form1中做的事情:
void PopulateApplications()
{
DoubleBufferedd(dataGridView1, true);
int rcount = dataGridView1.Rows.Count;
int rcurIndex = 0;
foreach (Process p in Process.GetProcesses())
{
try
{
if (File.Exists(p.MainModule.FileName))
{
memoryUsage = Core.getallmemoryusage(p.ProcessName);
Core.getcpu(p.ProcessName);
cpuusage = Core.processes;
var icon = Icon.ExtractAssociatedIcon(p.MainModule.FileName);
Image ima = icon.ToBitmap();
ima = resizeImage(ima, new Size(25, 25));
ima = (Image)(new Bitmap(ima, new Size(25, 25)));
String status = p.Responding ? "Running" : "Not Responding";
if (rcurIndex < rcount - 1)
{
var currentRow = dataGridView1.Rows[rcurIndex];
currentRow.Cells[0].Value = ima;
currentRow.Cells[1].Value = p.ProcessName;
currentRow.Cells[2].Value …Run Code Online (Sandbox Code Playgroud) 我有一个程序,其中有一个主题(如论坛),人们可以对该主题作出反应.
用户:
话题:
反应:
码:
List<USER> ListOfAllUsers = new List<USER>();
var AllReactions = from r in db.REACTIONs
where r.topic_id == _topic_id
select r;
foreach (var itemX in AllReactions)
{
ListOfAllUsers.Add(itemX.USER);
}
//Distinct the list of duplicates
var ListOfUsers = ListOfAllUsers.Distinct().ToList();
Run Code Online (Sandbox Code Playgroud)
现在,"distinct"列表仍然有一些重复,如何根据用户ID区分列表?或者也许有另一种更好的方法来做到这一点.提前致谢.
我有一个C#代码,如下所示:
foreach (var entry in this.ChangeTracker.Entries()
.Where(e => e.Entity is IAuditableTable &&
e.State == EntityState.Added))
{
IAuditableTable e = (IAuditableTable)entry.Entity;
e.ModifiedDate = DateTime.Now;
}
Run Code Online (Sandbox Code Playgroud)
这似乎就像foreach和LINQ的结合.sometone告诉我,我可以删除foreach并将其合并到一个LINQ语句中
在我的C#代码中,我使用XmlDocument 引用XML文件"file.xml",该文件与可执行文件本身位于同一目录中.
该应用程序在VS中运行得非常好,但是当我尝试使用Task Scheduler运行应用程序时,我得到了一个System.IO.FileNotFoundException,即使一切都是一样的.
我使用引用文件@".\file.xml".这是特定于任务计划程序的一些奇怪的东西吗?使用适当的权限.
我是C#的新手,我正在学习它,它只是一个虚拟测试程序.我收到了这篇文章标题中提到的错误.下面是C#代码.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace DriveInfos
{
class Program
{
static void Main(string[] args)
{
Program prog = new Program();
prog.propertyInt = 5;
Console.WriteLine(prog.propertyInt);
Console.Read();
}
class Program
{
public int propertyInt
{
get { return 1; }
set { Console.WriteLine(value); }
}
}
}
}
Run Code Online (Sandbox Code Playgroud) c# ×8
.net ×1
asp.net ×1
class ×1
constructor ×1
database ×1
distinct ×1
enums ×1
javascript ×1
linq ×1
linq-to-sql ×1
list ×1
member ×1
names ×1
oop ×1
query-string ×1
sql ×1
sql-server ×1
url ×1
winforms ×1