H
hal
I'm creating an asp.net page using c# and javascript. I have three
different controls on the page, and only when all three have been
accessed i want an imagebutton to go from disabled to enabled and
change its image. I somewhat got it working. I'm able to change the
image and have the imagebutton go from disabled to enabled using one
control at a time, but can't figure out to have the button do this
only after all three controls have been accessed. Below is my code:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>
<script type="text/javascript">
function SetImage()
{
if
((window.document.getElementById("TextBox1").attributes.length > 0) &&
(window.document.getElementById("DropDownList1").attributes.length >
0) &&
(window.document.getElementById("CheckBox1").attributes.length > 0))
{
document.all("ImageButton1").src = "Images/
enable.jpg";
window.document.getElementById("ImageButton1").disabled = false;
}
}
</script>
<form id="Form1" method="post" runat="server">
<aspropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Select A Location</asp:ListItem>
<asp:ListItem>Virginia</asp:ListItem>
<asp:ListItem>Florida</asp:ListItem>
<asp:ListItem>New York</asp:ListItem>
</aspropDownList>
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server"
onkeyup="SetImage()"></asp:TextBox>
<br />
<br />
<asp:CheckBox ID="CheckBox1" onclick="SetImage()" Text="I
Agree" runat="server" />
<br />
<br />
<asp:ImageButton ID="ImageButton1" Enabled="False"
runat="server" ImageUrl="~/Images/disable.jpg" />
</form>
</body>
</html>
/////CODE BEHIND//////
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.Attributes.Add("onchange", "SetImage()");
}
}
different controls on the page, and only when all three have been
accessed i want an imagebutton to go from disabled to enabled and
change its image. I somewhat got it working. I'm able to change the
image and have the imagebutton go from disabled to enabled using one
control at a time, but can't figure out to have the button do this
only after all three controls have been accessed. Below is my code:
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>
<script type="text/javascript">
function SetImage()
{
if
((window.document.getElementById("TextBox1").attributes.length > 0) &&
(window.document.getElementById("DropDownList1").attributes.length >
0) &&
(window.document.getElementById("CheckBox1").attributes.length > 0))
{
document.all("ImageButton1").src = "Images/
enable.jpg";
window.document.getElementById("ImageButton1").disabled = false;
}
}
</script>
<form id="Form1" method="post" runat="server">
<aspropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Select A Location</asp:ListItem>
<asp:ListItem>Virginia</asp:ListItem>
<asp:ListItem>Florida</asp:ListItem>
<asp:ListItem>New York</asp:ListItem>
</aspropDownList>
<br />
<br />
<asp:TextBox ID="TextBox1" runat="server"
onkeyup="SetImage()"></asp:TextBox>
<br />
<br />
<asp:CheckBox ID="CheckBox1" onclick="SetImage()" Text="I
Agree" runat="server" />
<br />
<br />
<asp:ImageButton ID="ImageButton1" Enabled="False"
runat="server" ImageUrl="~/Images/disable.jpg" />
</form>
</body>
</html>
/////CODE BEHIND//////
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.Attributes.Add("onchange", "SetImage()");
}
}