Cipher
08-31-2006, 06:41 AM
Hi Developers,
I'm trying to use a JavaScript function in UserControl but it doesnt work, i made a simple example of what i'm trying to do
in the UserControl.ascx:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input id="Button1" type="button" value="button" onclick="addText();" />
i try this function "addText()" in several places, the UserControl.ascx and the Default.aspx in different ways also:
function addText()
{
document.forms[0].TextBox1.value = "Hello World";
//document.form1.TextBox1.value = "Hello World";
// document.getElementById("TextBox1").value = "Hello World";
}
and always give me the same error that "TextBox1" is null or not an object.
Thank you for help.
I'm trying to use a JavaScript function in UserControl but it doesnt work, i made a simple example of what i'm trying to do
in the UserControl.ascx:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input id="Button1" type="button" value="button" onclick="addText();" />
i try this function "addText()" in several places, the UserControl.ascx and the Default.aspx in different ways also:
function addText()
{
document.forms[0].TextBox1.value = "Hello World";
//document.form1.TextBox1.value = "Hello World";
// document.getElementById("TextBox1").value = "Hello World";
}
and always give me the same error that "TextBox1" is null or not an object.
Thank you for help.