Professional Web Applications Themes

Controls with a client side onLoad function or seting a cursor server side - ASP.NET Building Controls

Is there any way to create a web control that calls a client side onLoad function? Its diffucilt since you are not able to access the form or body tags in the control. I inherit from: System.Web.UI.WebControls.WebControl What I'm really trying to do is set a cursor, i haven't been able to set it server side only in JavaScript. Any help would be great....

  1. #1

    Default Controls with a client side onLoad function or seting a cursor server side

    Is there any way to create a web control that calls a client side
    onLoad function?

    Its diffucilt since you are not able to access the form or body tags
    in the control.

    I inherit from:
    System.Web.UI.WebControls.WebControl

    What I'm really trying to do is set a cursor, i haven't been able to
    set it server side only in JavaScript.

    Any help would be great.
    Geoff Davis Guest

  2. #2

    Default Re: Controls with a client side onLoad function or seting a cursor server side

    I worked it out.

    By overiding Render, calling base.Render(output) and then adding to
    the HTML output stream i can run a script after the control had been
    rendered. Previously i could only run a script before it was rendered
    and that meant the control didn't exist yet.

    //In custom control (which is a composite control)
    protected override void Render(HtmlTextWriter output)
    {
    //add HTML components to the output stream
    base.Render(output);

    StringWriter s = new StringWriter();s.WriteLine("
    <script language='JavaScript'>
    doent.getElementById('MyControl').style.cursor = 'newCursor.cur';
    </script>");
    output.WriteLine(s.ToString());
    }

    [email]geoffrey.daviscsiro.au[/email] (Geoff Davis) wrote in message news:<6dfb2422.0401122159.41c4816fposting.google. com>...
    > Is there any way to create a web control that calls a client side
    > onLoad function?
    >
    > Its diffucilt since you are not able to access the form or body tags
    > in the control.
    >
    > I inherit from:
    > System.Web.UI.WebControls.WebControl
    >
    > What I'm really trying to do is set a cursor, i haven't been able to
    > set it server side only in JavaScript.
    >
    > Any help would be great.
    Geoff Davis Guest

  3. #3

    Default Re: Controls with a client side onLoad function or seting a cursor server side

    Although that approach is valid, the recommended approach is to use
    Page.RegisterStartUpScript method.
    Look it up in the SDK doc.

    "Geoff Davis" <geoffrey.daviscsiro.au> wrote in message
    news:6dfb2422.0401131549.7b421e00posting.google.c om...
    > I worked it out.
    >
    > By overiding Render, calling base.Render(output) and then adding to
    > the HTML output stream i can run a script after the control had been
    > rendered. Previously i could only run a script before it was rendered
    > and that meant the control didn't exist yet.
    >
    > //In custom control (which is a composite control)
    > protected override void Render(HtmlTextWriter output)
    > {
    > //add HTML components to the output stream
    > base.Render(output);
    >
    > StringWriter s = new StringWriter();s.WriteLine("
    > <script language='JavaScript'>
    > doent.getElementById('MyControl').style.cursor = 'newCursor.cur';
    > </script>");
    > output.WriteLine(s.ToString());
    > }
    >
    > [email]geoffrey.daviscsiro.au[/email] (Geoff Davis) wrote in message
    news:<6dfb2422.0401122159.41c4816fposting.google. com>...
    > > Is there any way to create a web control that calls a client side
    > > onLoad function?
    > >
    > > Its diffucilt since you are not able to access the form or body tags
    > > in the control.
    > >
    > > I inherit from:
    > > System.Web.UI.WebControls.WebControl
    > >
    > > What I'm really trying to do is set a cursor, i haven't been able to
    > > set it server side only in JavaScript.
    > >
    > > Any help would be great.

    Jiho Han Guest

  4. #4

    Default Re: Controls with a client side onLoad function or seting a cursor server side

    Thanks, I gave it a go,

    I wasn't sure if you could register more than one start up script.

    I didn't want to make it so I remove the ability for someone using my
    control to be able to register a start up script.

    but you can register many if you want to.

    thanks.



    "Jiho Han" <jiho.haninfinityinfo.com> wrote in message news:<eIrPm6q2DHA.2184TK2MSFTNGP12.phx.gbl>...
    > Although that approach is valid, the recommended approach is to use
    > Page.RegisterStartUpScript method.
    > Look it up in the SDK doc.
    Geoff Davis Guest

Similar Threads

  1. flashcom: client side cant access server side
    By u_sq in forum Macromedia Flash Flashcom
    Replies: 1
    Last Post: June 28th, 09:16 PM
  2. Is PHP client-side or server-side?
    By Konrad Den Ende in forum PHP Development
    Replies: 11
    Last Post: October 31st, 12:24 PM
  3. Replies: 9
    Last Post: October 17th, 07:25 PM
  4. server-side ASP w/ client -side component
    By Miguel Guerreiro in forum ASP Components
    Replies: 1
    Last Post: August 5th, 12:09 AM
  5. button evet ---- server side - client side ???
    By yaya coco in forum ASP.NET General
    Replies: 1
    Last Post: July 4th, 10:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139