c# - asp.net aspx OnClick 在客户端服务过程中单击时不会触发
问题描述
我有 Default.cs 文件和 Default.aspx.cs 文件。我使用 OnClick 和 OnServerClick 方法实现 rules_abort_execution_button 的地方。这两个功能都在 Default.cs UI 按钮中实现:Default.aspx.cs
<div id="rules_execution_dialog" runat="server" class="theme-border">
<div id="rules_execution_dialog_drag_control" title="Drag me">
<img id="rules_execution_dialog_maximize_button" src="./Resources/Theme/Images/maximize.png" alt="Maximize" title="Maximize" />
<br style="clear: both" />
</div>
<div style="margin-top: 10px">
<input class="btn" id="rules_execute_close_button" type="button" value="Close" disabled="disabled" onclick=" dialogClosed($('rules_execution_dialog')) " style="float: right; min-width: 0px; width: 70px;" />
<input class="btn" id="rules_abort_execution_button" type="button" value="Abort execution" runat="server" OnClick="abort_click" OnServerClick="btn_Abort_Click" style="float: right; min-width: 0px; width: 90px;" />
<br style="clear: both" />
</div>
</div>
我Default.cs
的两个功能:
protected void btn_Abort_Click(object sender, EventArgs e)
{
var IamHere = "";
return;
}
protected void abort_click(object sender, EventArgs e)
{
var test = "";
return;
}
当我从另一个文件执行 Soap 客户端方法Download.cs
以获取数据时,它需要很长时间,所以我想添加可以允许中止执行的中止按钮。但不幸的是,在从第三方客户端获取数据时,我的 UI 没有响应我的 UI 单击按钮方法。我尝试了各种示例,但没有找到解决方案。
解决方案
OnClick="abort_click" OnServerClick="btn_Abort_Click"
Onclick 应该是 javascript
示例代码
<%@ Page Title="About" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="WebApplication2.About" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<h2><%: Title %>.</h2>
<h3>Your application description page.</h3>
<p>Use this area to provide additional information.</p>
<input id="Button1" type="button" value="button" runat="server" onclick="alert('hi');" onserverclick="Button1_ServerClick"/>
</asp:Content>
服务器端
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication2
{
public partial class About : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_ServerClick(object sender, EventArgs e)
{
Response.Write("hello");
}
}
}
推荐阅读
- python - 在 Pyspark 中查找两个日期之间的周末天数
- c# - 加载 X509Certificate2 间歇性错误
- reactjs - React JS:向 const 添加键和值
- python - 使用 Python 请求从 URL 下载 PDF
- powershell - Powershell:使用 WHERE 选择数组的一部分
- javascript - JavaScript NodeJS 缓冲区
- python - 如何针对某些用户选择/位置更改此程序中的变量?
- java - JAVA:在编译时加载静态值有什么好处?
- python - 使用 Django 时 VS Code 中的 pylance(reportMissingModuleSource) 错误
- c - 在星号后取消函数指针间距