Hi,
document.write doesn't work with update panel. It works without update panel. That's for IE. document.write() kind of works in Firefox, but it clears all page content that was before document.write executed. Here is the code:
<%@dotnet.itags.org. Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
Page.ClientScript.RegisterStartupScript(GetType(), "hello", "hello();", true);
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script language="javascript" type="text/javascript">
function hello()
{
alert('Hello World!');
document.write('Hello World!');
placeholder.innerHTML = 'Hello World...';
}
</script>
</head>
<body>
<atlas:ScriptManager ID="ScriptManager" runat="server" EnablePartialRendering="true" />
<form id="form1" runat="server">
<atlas:UpdatePanel ID="p1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
<div id="placeholder"></div>
</ContentTemplate>
</atlas:UpdatePanel>
</form>
</body>
</html>
PS. forRegisterStartupScriptto work in firefox seehttp://forums.asp.net/thread/1239150.aspx
hello.
can you tell us what do you mean by doesn't work? i've copied your code and it seems like it's working with ie6...maybe i'm missing something?
I actually was testing it in IE7b2. But I just tested in IE6 and it still doesn't work.
The expected output of the above code:
message boxHello World!
Hello World!by document.write (this line is missing)
Hello World...set by placeholder.innerHTML property (works, but not in FF though)
hello.
well, i've tried it here and with firefox it seems to be working, ie, document.write replaces the content of the body with the string that is passed to it.
btw, the placeholder.innerHTML isn't working because it should be document.getElementById("placeholder").innerHTML.
No comments:
Post a Comment