2

I have Default.cs file with Default.aspx.cs file. Where I implemented rules_abort_execution_button with OnClick and OnServerClick methods. Both functions are implemented in Default.cs UI button: 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>

My Default.cs with both functions:

protected void btn_Abort_Click(object sender, EventArgs e)
{
    var IamHere = "";
    return;
}

protected void abort_click(object sender, EventArgs e)
{
    var test = "";
    return;
}

When I am executing Soap client method from another file Download.cs to get a data it takes quite long , so I would like to add abort button which could allow abort execution. But unfortunately while fetching data from third part client my UI do not response to my UI click button methods. I tried various examples and I didnt found solution.

Alexander
  • 9,104
  • 1
  • 17
  • 41
BinaryTie
  • 281
  • 1
  • 21
  • 49
  • 1
    you need to start the `SOAP` call in `different Thread` as it is running on `UI thread` and making the `thread wait` until it is finishing, when you invoke `SOAP` call in a different `thread` your `UI thread` will not be hanged and you will be able to `click` on `Abort button`. Hope this helps. – Abhinaw Kaushik Mar 20 '19 at 04:17

1 Answers1

0

OnClick="abort_click" OnServerClick="btn_Abort_Click"

Onclick should be javascript

sample code

 <%@ 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>

Server side

    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");
        }
    }
}
Jin Thakur
  • 2,711
  • 18
  • 15