RE: Controls not updated by callback event



Hi Dave,

Some updates:

<html>
<head>
<title>Test Page</title>

<script language="javascript" type="text/javascript">
function MyControl1OnSuccess(text) {
//alert(text);
document.getElementById("Label1").innerHTML = text;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<custom:MyControl ID="MyControl1" OnMyEvent="Wrapper1_Save"
runat="server" />
<asp:Button ID="Button1" Text="PostBack" runat="server"
OnClick="Button1_Click" />
<asp:Button ID="Button2" Text="CallBack"
OnClientClick="MyControl1Callback('Testing123', null); return false;"
runat="server" />
<asp:Label ID="Label1" runat="server" />
</div>
</form>
</body>
</html>


1) To update the label's content on callback, use DHTML dom elements to
change its content.

2) You need to add "return false" in button2's OnClientClick, otherwise
there's an additional normal postback at the end (which will re-render the
page content according to server-side controls' states -- which means the
label1's content that we changed via script callback will be overwritten
again).


Hope this helps.


Regards,
Walter Wang (wawang@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

.


Loading