| |

VerySource

 Forgot password?
 Register
Search
View: 676|Reply: 5

How to solve the problem of button response? (anxious!!!)

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-20 01:00:01
| Show all posts |Read mode
Two datagrids are made in one page, as a voting option, and the next voting button, I want to make the button Enabled = false after clicking the voting button, but the button needs to be refreshed after the page properties (because there are more voting items, So it takes a certain amount of time to update the data, so it is only possible to change it in order to prevent repeated submissions. Is there any other way to directly change its properties after clicking. Thanks for the solution!
Reply

Use magic Report

0

Threads

60

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-1-28 16:00:02
| Show all posts
js implementation

<% @ Page Language = "C #" AutoEventWireup = "true" CodeFile = "aaa.aspx.cs" Inherits = "aaa"%>

<! DOCTYPE html PUBLIC "-// W3C // DTD XHTML 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns = "http://www.w3.org/1999/xhtml">
<head runat = "server">
    <title> Untitled page </ title>
</ head>
<body>
    <form id = "form1" runat = "server">
    <div>
      <asp: TextBox ID = "TextBox1" runat = "server"> </ asp: TextBox>
      <asp: Button ID = "Button1" runat = "server" OnClick = "Button1_Click" Text = "Button" OnClientClick = "this.form.submit (); this.disabled = true" UseSubmitBehavior = "False" /> </ div>
    </ form>
</ body>
</ html>


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class aaa: System.Web.UI.Page
{
  protected void Page_Load (object sender, EventArgs e)
  {
    if (Page.IsPostBack)
    {
      Button1.Attributes.Add ("disabled", "disabled");
    }
  
  }
  protected void Button1_Click (object sender, EventArgs e)
  {
    string a = TextBox1.Text;
    Response.Write (a);
  }
}
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-1-29 22:54:01
| Show all posts
Tried it, but it became unavailable directly after clicking submit without updating the data.
Reply

Use magic Report

0

Threads

60

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-1-30 09:45:01
| Show all posts
UseSubmitBehavior = "False"
Delete try
Reply

Use magic Report

0

Threads

73

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-1-30 10:45:01
| Show all posts
<body>
    <form id = "form1" runat = "server">
    <div>
      <asp: TextBox ID = "TextBox1" runat = "server"> </ asp: TextBox>
      <asp: Button ID = "Button1" runat = "server" Text = "Button" OnClientClick = "document.form1.btn2.click (); this.disabled = true" />
<asp: Button ID = "btn2" runat = "server" OnClick = "Button1_Click" Text = "Button" />
</ div>
    </ form>

Page_Load () writes:
btn2.Attributes.Add ("style", "display: none");
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-30 11:18:02
| Show all posts
There is only one solution
With an html button, a server-side button, set the server-side button to be invisible
When pressing the html button, write a JS, html button name. Enable = false, and perform the click process of the server-side button

After performing the postback, write a js code html button name on the server side. Enable = true

The specific code of the web form is as follows:
js code
function Send (val)
  {
  document.all.BtnSend.click ();
  document.all.BtnSending.disabled = true;
    
  }
form
<form id = "FormRoleSet" method = "post" runat = "server">
<!-Here is the html button->
 <input style = "WIDTH: 141px; HEIGHT: 20px" id = "BtnSending" name = "BtnSending" onclick = "Send ()"
type = "button" value = "Send mail">
<!-Here is the server-side button->
<asp: button id = "BtnSend" style = "DISPLAY: none" runat = "server" Width = "133px" Text = "Send Email"> </ asp: button>
</ form>

After processing on the server side, go to your page itself or use js to display the button.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list