disable a button until a link is clicked

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,
 
M

mick0987b

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>
 
C

Cubaman

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,

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top