disable a button until a link is clicked

  • Thread starter Thread starter Betty
  • Start date Start date
B

Betty

Hi,

If I want a button non-clickable until a link above the button is
clicked(i.e., an legal informational page is viewed then a user can go on to
the next page by clicking the button), how can I implement it?

thanks,
 
This any good for you?


<%@ Page Language="VB" %>

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

<script runat="server">

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Response.Redirect("nextpage.aspx")
End Sub

Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Button1.Enabled = True
End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:LinkButton ID="LinkButton1" runat="server"
onclick="LinkButton1_Click">This is the link, click this first</
asp:LinkButton>

</div>
<asp:Button ID="Button1" runat="server" Enabled="False"
onclick="Button1_Click"
Text="Button" />
</form>
</body>
</html>
 
Hi,

If I want a button non-clickable until a link above the button is
clicked(i.e., an legal informational page is viewed then a user can go onto
the next page by clicking the button), how can I implement it?

thanks,

You can also achieve the same result using javascript, avoiding
postback an improving user experience.

On link click:

ClientScript.RegisterStartupScript(this, "document.getElementById('" +
Button1.ClientId + "').enabled = true;", true);
 
Back
Top