Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Pb using client side function insertAdjacentHTML

Author  Topic 

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-09-17 : 17:49:41


Here the script I put in my page_load:

string scriptString="<Script Language=JavaScript> function fnAdd() {";

scriptString += "document.body.insertAdjacentHTML('BeforeEnd','<P>' + document.getElementById('oText').value + '<P>');}<";

scriptString+="/";

scriptString+="script>";

this.RegisterClientScriptBlock("fnAddit",scriptString);

this.Button1.Attributes.Add("onClick","fnAdd()");

Can u tell me pls how I can make the text of 'oText' still on the page instead of its appearing then disapearing right way

Thanks

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-09-17 : 18:34:16
Here the html code I get but the value of oText appears only one second then disappears:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm2</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="WebForm2.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE" value="dDwxMjU3NDE4Mzg1O3Q8O2w8aTwxPjs+O2w8dDw7bDxpPDE+Oz47bDx0PHA8O3A8bDxvbkNsaWNrOz47bDxmbkFkZCgpOz4+Pjs7Pjs+Pjs+Pjs+Cn6fDvNDvA93cOxr1+rKsI+oBuQ=" />
<Script Language=JavaScript> function fnAdd() {document.body.insertAdjacentHTML('BeforeEnd','<P>' + document.getElementById('oText').value + '<P>');}</script>


<input type="submit" name="Button1" value="bouttona" id="Button1" onClick="fnAdd()" style="Z-INDEX: 101; LEFT: 376px; POSITION: absolute; TOP: 184px" />
<input name="oText" type="text" value="watext" id="oText" style="Z-INDEX: 102; LEFT: 384px; POSITION: absolute; TOP: 112px" />
</form>
</body>
</HTML>

Thanks
Go to Top of Page
   

- Advertisement -