具有 onclick 事件的 SharePoint Dataview 行中的 asp:Button 不调用 C# 函数。将其从 Dataview 中拉出并且工作正常

发布于 2024-09-19 20:08:05 字数 715 浏览 7 评论 0原文

具有 onclick 事件的 SharePoint Dataview 行中的 asp:Button 不调用 C# 函数。将其从 Dataview 中拉出并且工作正常。

我有一个 ASP.NET 按钮,放置在 SharePoint DataView 的行内,其中的 onclick 事件指向页面内的 C# 功能块。当我点击它们时,页面会刷新,但它没有点击该代码块。如果我将按钮移到数据视图之外并固定 ID,则代码可以完美运行。这是怎么回事?

Dataview 中的按钮:

<asp:Button runat="server" Text="Delete" id="Delete{@ID}" CommandArgument="{@FileRef}" OnClick="DeleteDoc"/>

我的 C# onclick 处理程序(页面上的内联 C#)

void DeleteDoc(object sender, EventArgs e){sendmail("DeleteDoc");Button b = sender as button;.. more code

这都是内联代码,我正在使用 SharePoint Designer。不知道如何解决这个问题。

我是否在这里遗漏了一些东西,也许我需要添加一个 Itemtemplate 或类似我们在 ASP.NET gridview 控件中需要的东西?

谢谢。

asp:Button inside SharePoint Dataview Rows with onclick event does not call C# function. Pull it out of Dataview and works fine.

I have a ASP.NET Button I've placed inside a SharePoint DataView's rows with an onclick event pointing to C# function block inside my page. The page refreshes when I click on them, but it's not hitting that code block. If I move the button to outside the dataview and make the ID fixed, the code works beautifully. what's up with that?

the button in the Dataview:

<asp:Button runat="server" Text="Delete" id="Delete{@ID}" CommandArgument="{@FileRef}" OnClick="DeleteDoc"/>

my C# onclick handler (inline C# on the page)

void DeleteDoc(object sender, EventArgs e){sendmail("DeleteDoc");Button b = sender as button;.. more code

This is all inline code and I'm working from SharePoint Designer. Not sure how I can troubleshoot this.

Am I missing something here, maybe I need to add an Itemtemplate or something like we need to in a ASP.NET gridview controls?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

2024-09-26 20:08:24

IIRc,您需要使用操作,而不是事件。

IIRc, you need to use Actions, not events.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文