Groups | Blog | Home
all groups > asp.net > august 2006 >

asp.net : Dynamically generating Javascript


Fernando Chilvarguer
8/31/2006 6:31:44 PM
Here's my scenario:

I have one page, one control, and I want the control to generate a
javascript to the page based on parameters passed by the queryString.

ASPX Code:
....
<head>
<title>TItle</title>

<uc1:MyControl ID="myControl1" runat="server" />

<script type="text/javascript">
function function2(id,myText){
document.getElementById(id).innerHTML=myText
}

function function3(id,myText){
document.getElementById(id).innerHTML=function1(myText)
}
</script>
....

The output of "myControl1" is the javascript called "function1", which is
called by function3

But for some reason it does not work, I get the "Object expected" error in
javascript (can't find function1).
I'm assuming it has to do with the page life-cycle but I have no idea.
Any help will be very appreciated.

Thanks,
Fernando

bruce barker (sqlwork.com)
9/1/2006 8:15:16 AM
look at the page source. also check that the ids passed to functions match
the rendered ids.

-- bruce (sqlwork.com)

[quoted text, click to view]

AddThis Social Bookmark Button