shawndg
7/15/2011 7:46:49 PM
Ok..
I started implemented my own control..
I added a snippet of Javascript
<script language="JavaScript">
function TestMe()
{
var mytest = prompt('Enter a string','');
if ((mytest) && (mytest != ""))
{
document.forms[0].elements['TestValue'].value = mytest;
__doPostBack('TestMe', '');
}
}
</script>
And a little bit of ASP Markup..
<a href="javascript:TestMe();">Create Text file</a>
<asp:linkbutton id="TestMe" runat="server" onclick="TestMe_Click" />
<input type="hidden" runat="server" id="TestValue">
and then some code behind..
protected void TestMe_Click(object sender, EventArgs e)
{
string strTestMe = TestValue.Value;
}
Then ran it and clicked on my button and now inside my script I can see a error..
<script language="JavaScript">
function TestMe()
{
var mytest = prompt('Enter a string','');
if ((mytest) && (mytest != ""))
{
document.forms[0].elements['TestValue'].value = mytest; this line errors,
__doPostBack('TestMe', '');
}
}
</script>
SCRIPT5007: Unable to set value of the property 'value': object is null or undefined
Im thinking... since I am putting these controls inside of a webpart..
The ref is not correct.. document.forms[0] ... i tried 'form1' it
errors, and then instead i tried a array of forms[0] and it errors too.
Now Im not a javascript expert.. but I think the problem is with the controls and their call backs.
Im thinking.. the javascript is unable to find the form object.. because its nested inside a monox web control.
Any thoughts ?
This content has not been rated yet.
1871
Reputation
252
Total posts