Dynamically generating Javascript

Discussion in 'ASP .Net' started by Fernando Chilvarguer, Sep 1, 2006.

  1. 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
     
    Fernando Chilvarguer, Sep 1, 2006
    #1
    1. Advertisements

  2. look at the page source. also check that the ids passed to functions match
    the rendered ids.

    -- bruce (sqlwork.com)
     
    bruce barker \(sqlwork.com\), Sep 1, 2006
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.