我有以下代码:
public ActionResult SomeAction()
{
return new JsonpResult
{
Data = new { Widget = "some partial html for the widget" }
};
}
Run Code Online (Sandbox Code Playgroud)
我想修改它以便我可以
public ActionResult SomeAction()
{
// will render HTML that I can pass to the JSONP result to return.
var partial = RenderPartial(viewModel);
return new JsonpResult
{
Data = new { Widget = partial }
};
}
Run Code Online (Sandbox Code Playgroud)
这可能吗?有人可以解释一下吗?
请注意,我在发布解决方案之前编辑了问题.
我们正在使用Elmah作为我们的错误记录系统,用于即将投入生产的应用程序.它非常有用,但是如果像这样投入生产,世界上任何人都可以访问错误日志,因为他们所要做的就是访问ourdomain.com/elmah.axd
.
这显然不太理想.我原本打算将访问该页面仅限于我们公司内的IP地址,但现在我们的SysAdmins说这是不可能的.所以我在这里问我怎么能阻止访问这个资源?
我们在IIS 6上运行ASP.NET MVC应用程序.
我需要将两个div相互对齐,这样每个div都包含一个标题和一个项目列表,类似于:
<div>
<span>source list</span>
<select size="10">
<option />
<option />
<option />
</select>
</div>
<div>
<span>destination list</span>
<select size="10">
<option />
<option />
<option />
</select>
</div>
Run Code Online (Sandbox Code Playgroud)
使用表格非常容易,但我不想使用表格.我怎样才能做到这一点?
使用标记生成器和字符串生成器在htmlhelper类中创建表或使用HtmlTable有什么区别?
他们不是生成同样的事情吗?
什么是Projection,在数据库理论和NHibernate方面使用SetProjection()?
我正在尝试创建一个包含许多静态html表的页面.
我需要做些什么才能让它们显示与表中每个列相同大小的每个列?
HTML如下:
<span class="Emphasis">Interest rates</span><br />
<table cellpadding="0px" cellspacing="0px" class="PerformanceTable">
<tr><th class="TableHeader"></th><th class="TableHeader">Current rate as at 31 March 2010</th><th class="TableHeader">31 December 2009</th><th class="TableHeader">31 March 2009</th></tr>
<tr class="TableRow"><td>Index1</td><td class="PerformanceCell">1.00%</td><td>1.00%</td><td>1.50%</td></tr>
<tr class="TableRow"><td>index2</td><td class="PerformanceCell">0.50%</td><td>0.50%</td><td>0.50%</td></tr>
<tr class="TableRow"><td>index3</td><td class="PerformanceCell">0.25%</td><td>0.25%</td><td>0.25%</td></tr>
</table>
<span>Source: Bt</span><br /><br />
<span class="Emphasis">Stock markets</span><br />
<table cellpadding="0px" cellspacing="0px" class="PerformanceTable">
<tr><th class="TableHeader"></th><th class="TableHeader">As at 31 March 2010</th><th class="TableHeader">1 month change</th><th class="TableHeader">QTD change</th><th class="TableHeader">12 months change</th></tr>
<tr class="TableRow"><td>index1</td><td class="PerformanceCell">1169.43</td><td class="PerformanceCell">5.88%</td><td class="PerformanceCell">4.87%</td><td class="PerformanceCell">46.57%</td></tr>
<tr class="TableRow"><td>index2</td><td class="PerformanceCell">1958.34</td><td class="PerformanceCell">7.68%</td><td class="PerformanceCell">5.27%</td><td class="PerformanceCell">58.31%</td></tr>
<tr class="TableRow"><td>index3</td><td class="PerformanceCell">5679.64</td><td class="PerformanceCell">6.07%</td><td class="PerformanceCell">4.93%</td><td …
Run Code Online (Sandbox Code Playgroud) 我需要一个脚本中的功能,使我能够在表中插入日期.
我需要什么SQL来插入格式的日期
01/08/2010 00:00:00
Run Code Online (Sandbox Code Playgroud)
其中日期是当月的第一天.我需要更改订单才能指定月份值?谢谢
我有以下PerformanceFactsheet.aspx.cs页面类
public partial class PerformanceFactsheet : FactsheetBase
{
protected void Page_Load(object sender, EventArgs e)
{
// do stuff with the data extracted in FactsheetBase
divPerformance.Controls.Add(this.Data);
}
}
Run Code Online (Sandbox Code Playgroud)
FactsheetBase定义为
public class FactsheetBase : System.Web.UI.Page
{
public MyPageData Data { get; set; }
protected void Page_Load(object sender, EventArgs e)
{
// get data that's common to all implementors of FactsheetBase
// and store the values in FactsheetBase's properties
this.Data = ExtractPageData(Request.QueryString["data"]);
}
}
Run Code Online (Sandbox Code Playgroud)
问题是FactsheetBase的Page_Load没有执行.
谁能告诉我我做错了什么?有没有更好的方法来获得我追求的结果?
谢谢
在一个例子中,我的教授已经实现了Equals如下:
public class Person {
private string dni;
// ...
public override bool Equals(object o) {
if (o == null)
return (this == null);
else {
return ((o is Person) && (this.dni == (o as Person).dni));
}
}
}
Run Code Online (Sandbox Code Playgroud)
我没有使用C#的经验,但据我所知,this
在成员函数中不能为null(至少在C++和Java中,我知道的语言是这样)所以if看起来很奇怪.
我是对的还是c#中有任何组件我不知道哪个使测试成为this == null
必要的?
asp.net-mvc ×4
c# ×3
css ×2
html ×2
.net ×1
asp.net ×1
database ×1
date ×1
datetime ×1
elmah ×1
equals ×1
html-helper ×1
html-table ×1
iis-6 ×1
moq ×1
nhibernate ×1
nunit ×1
oop ×1
security ×1
sql ×1
sql-server ×1
tagbuilder ×1
unit-testing ×1