A
andrew.douglas11
Hello - I'm trying to dynamically change an asp:HyperLink's text
through JavaScript, and finding that the new value that's set in
JavaScript doesn't get posted back. I've tried to explicitly set
EnableViewState to "True", but that doesn't help. Is there a better
way to do this and still update the text through client-side code?
The entire code appears below (no 'code behind' code).
Thanks!
Andy
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb"
Inherits="Test" %>
<!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>
<script>
function updateLink() {
document.getElementById("HyperLink1").innerText = "POSTBACK
PLEASE";
document.getElementById("DropDownList1").value = "2";
alert("pause to verify new values...");
//go ahead and post back
return true;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</
asp:HyperLink>
<br />
<aspropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="1"></asp:ListItem>
<asp:ListItem Value="2"></asp:ListItem>
</aspropDownList>
<br />
<asp:Button ID="Button1" runat="server" OnClientClick="return
updateLink()" Text="Button" />
</div>
</form>
</body>
</html>
through JavaScript, and finding that the new value that's set in
JavaScript doesn't get posted back. I've tried to explicitly set
EnableViewState to "True", but that doesn't help. Is there a better
way to do this and still update the text through client-side code?
The entire code appears below (no 'code behind' code).
Thanks!
Andy
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb"
Inherits="Test" %>
<!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>
<script>
function updateLink() {
document.getElementById("HyperLink1").innerText = "POSTBACK
PLEASE";
document.getElementById("DropDownList1").value = "2";
alert("pause to verify new values...");
//go ahead and post back
return true;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:HyperLink ID="HyperLink1" runat="server">HyperLink</
asp:HyperLink>
<br />
<aspropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="1"></asp:ListItem>
<asp:ListItem Value="2"></asp:ListItem>
</aspropDownList>
<br />
<asp:Button ID="Button1" runat="server" OnClientClick="return
updateLink()" Text="Button" />
</div>
</form>
</body>
</html>