我正在使用Ext.NET和VS2008,ASP.NET。我有一个独特的问题,我无法找到任何解决方案。
有一个GridPanel,在TopBar中有一个删除按钮。 Grid使用RowSelection模型。选择行后,用户单击“删除”按钮。引发客户端事件以确认以下是代码段
<ext:Button ID="btnDelete" runat="server" Text="Delete" Icon="Delete">
<DirectEvents>
<Click OnEvent="Evt_Delete">
<ExtraParams>
<ext:Parameter Name="recordId" Value="(#{grdSanction}).selModel.getSelected().data.VoucherID" Mode="Raw" />
</ExtraParams>
<Confirmation Message="Do you really want to delete sanction?" ConfirmRequest="true"/>
</Click>
</DirectEvents>
</ext:Button>
但问题是我点击是后我得到以下消息基本上是500内部服务器错误。
以下是我在Fiddler中找到的内容:
结果协议主机URL正文缓存内容类型进程注释自定义
1 500 HTTP onyx /pages/sanction.aspx?_dc=1337773867270 4,268 private text / html; charset = utf-8 chrome:920
VS2008的调试器不起作用,因为后面的代码上的事件永远不会引发。 工具栏上的其他按钮工作得很好。有谁知道我在这里失踪了什么?
答案 0 :(得分:1)
我认为你只需要删除#{grdSantion}
周围的圆括号。
// Not OK
(#{grdSanction}).selModel.getSelected().data.VoucherID
// OK
#{grdSanction}.selModel.getSelected().data.VoucherID
以下示例演示了完整方案,并且似乎可以按照您的要求运行。
示例强>
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
var store = this.GridPanel1.GetStore();
store.DataSource = this.Data;
store.DataBind();
}
}
private object[] Data
{
get
{
return new object[]
{
new object[] { "3m Co", 71.72, 0.02, 0.03, "9/1 12:00am" },
new object[] { "Alcoa Inc", 29.01, 0.42, 1.47, "9/1 12:00am" },
new object[] { "Altria Group Inc", 83.81, 0.28, 0.34, "9/1 12:00am" },
new object[] { "American Express Company", 52.55, 0.01, 0.02, "9/1 12:00am" },
new object[] { "American International Group, Inc.", 64.13, 0.31, 0.49, "9/1 12:00am" },
new object[] { "AT&T Inc.", 31.61, -0.48, -1.54, "9/1 12:00am" },
new object[] { "Boeing Co.", 75.43, 0.53, 0.71, "9/1 12:00am" },
new object[] { "Caterpillar Inc.", 67.27, 0.92, 1.39, "9/1 12:00am" }
};
}
}
protected void Button1_Click(object sender, DirectEventArgs e)
{
X.Msg.Notify("Company", e.ExtraParams["company"]).Show();
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:GridPanel
ID="GridPanel1"
runat="server"
Title="Array Grid"
Width="350"
Height="215">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button runat="server" Text="Delete" Icon="Delete">
<DirectEvents>
<Click OnEvent="Button1_Click">
<ExtraParams>
<ext:Parameter Name="company" Value="#{GridPanel1}.selModel.getSelected().data.company" Mode="Raw" />
</ExtraParams>
<Confirmation Message="Do you really want to delete sanction?" ConfirmRequest="true"/>
</Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Store>
<ext:Store runat="server">
<Reader>
<ext:ArrayReader>
<Fields>
<ext:RecordField Name="company" />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column ColumnID="Company" Header="Company" DataIndex="company" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" SingleSelect="true" />
</SelectionModel>
</ext:GridPanel>
</form>
</body>
</html>