I am using ASP.net Web forms
I have users register into my page
once they registered a 3rd pty code updates the database which can take between 1 sec and few minutes
I want to add a rotating spinner wheel while server is running and waiting for the 3rd pty response.
there is a loop with waiting to check the for 3rd pty result
what i want, is to have a spinner that shows the user that there is a process running in the backend
I tried to add asp:image with spinning gif, but when i call it it does not show till the process is finished
i wonder if there is an easy way to add the spinner
here is my code for reg.aspx
<div>
<div>Register</div>
<div>
<asp:TextBox ID="FirstName" runat="server" placeholder="First Name"></asp:TextBox>
</div>
<div>
<asp:TextBox ID="LastName" runat="server" placeholder="Last Name"></asp:TextBox>
</div>
<div>
<asp:TextBox ID="PhoneNumber" runat="server" placeholder="Phone Number"></asp:TextBox>
</div>
<div>
<asp:TextBox ID="Email" runat="server" placeholder="Email" TextMode="Email"></asp:TextBox>
</div>
<div>
<asp:TextBox ID="Password" runat="server" placeholder="Password" TextMode="Password"></asp:TextBox>
</div>
<div>
<asp:Label ID="ErrorMessage" runat="server" Visible="false" Text=""></asp:Label>
</div>
<div>
<asp:Image runat="server" ID="imgSpin" ImageUrl="~/images/spinner6.gif" Visible="true" />
</div>
<asp:Button ID="registerButton" runat="server" Text="Sign Up" OnClick="registerButton_Click" />
</form>
</body>
and here for reg.aspx.cs
protected void registerButton_Click(object sender, EventArgs e)
{
RegisterUser();
}
protected void RegisterUser()
{
imgSpin.Visible = true;
string firstName = FirstName.Text;
string lastName = LastName.Text;
string phoneNumber = PhoneNumber.Text;
string email = Email.Text;
string password = Password.Text;
Reg(firstName, lastName, phoneNumber, email, password);
string resultCode = "*";
bool bExit = false;
while (!bExit)
{
switch (resultCode.ToUpper())
{
case "ERROR":
ErrorMessage.Text = "Invalid user ID or password. Please try again.";
ErrorMessage.Visible = true;
bExit = true;
break;
case "OK":
Response.Redirect("job.aspx");
bExit = true;
break;
default:
// Wait 2 seconds, then call the procedure again
System.Threading.Thread.Sleep(2000);
resultCode = Call3Pty();
break;
}
}
imgSpin.Visible = false;
}
GPT suggested adding 2 event to the Signup button but that never works, only client side gets triggered but the backend never did
<asp:Button ID="registerButton" runat="server" Text="Sign Up" OnClick="registerButton_Click" OnClientClick="showSpinner();" />
how can i add a simple spinner while my code running in the background