Script control

Discussion in 'ASP .Net Building Controls' started by Magne Ryholt, Oct 16, 2004.

  1. Magne Ryholt

    Magne Ryholt Guest

    I have made a control based on System.Web.UI.WebControls.WebControl which
    override the Render method to emit a script
    (by using the Page.RegisterStartupScript() method)
    This works fine.

    This control does not render any HTML code except the mentioned script,
    therefore I would like to put the component (using VS.net 2003) on the
    component tray instead of the form.
    (otherwise it takes up space on thye form)

    Anyone knows if this is possible ?
     
    Magne Ryholt, Oct 16, 2004
    #1
    1. Advertising

  2. Magne Ryholt

    Jos Guest

    Magne Ryholt wrote:
    > I have made a control based on System.Web.UI.WebControls.WebControl
    > which override the Render method to emit a script
    > (by using the Page.RegisterStartupScript() method)
    > This works fine.
    >
    > This control does not render any HTML code except the mentioned
    > script, therefore I would like to put the component (using VS.net
    > 2003) on the component tray instead of the form.
    > (otherwise it takes up space on thye form)
    >
    > Anyone knows if this is possible ?


    I don't think so.
    To get your control in the component tray, you need to
    derive from Component instead of WebControl.

    But Component doesn't have a Render method.

    However, you could associate your control with a class
    derived from ControlDesigner, which would just emit some
    small code to show in the designer. This would solve
    your problem.

    Look here:
    http://msdn.microsoft.com/asp.net/d...s/dnaspp/html/aspnet-adddesigntimesupport.asp

    --

    Jos
     
    Jos, Oct 17, 2004
    #2
    1. Advertising

  3. Magne Ryholt

    Magne Ryholt Guest

    Thanks for your answer
    I beleive your answer indicates to emit some HTML for showing the control in
    design time, but still it will occupy space in the form designer ?
    I thought it might be a possibility to make it a "component" (in the
    component tray) because System.Web.UI.WebControls.WebControl inherits from
    System.Web.UI.Control
    which in turn inherits from (implements) IComponent, but I cannot find
    anything useful there either.

    Anyway, it is not a big problem, it just reminds me of the annoying way e.g.
    Visual Basic 6.0 showed (runtime-invisible)components in the form and took
    up some space :)
    (but VB 6.0 didn't have any "component tray")

    "Jos" <> wrote in message
    news:...
    > Magne Ryholt wrote:
    >> I have made a control based on System.Web.UI.WebControls.WebControl
    >> which override the Render method to emit a script
    >> (by using the Page.RegisterStartupScript() method)
    >> This works fine.
    >>
    >> This control does not render any HTML code except the mentioned
    >> script, therefore I would like to put the component (using VS.net
    >> 2003) on the component tray instead of the form.
    >> (otherwise it takes up space on thye form)
    >>
    >> Anyone knows if this is possible ?

    >
    > I don't think so.
    > To get your control in the component tray, you need to
    > derive from Component instead of WebControl.
    >
    > But Component doesn't have a Render method.
    >
    > However, you could associate your control with a class
    > derived from ControlDesigner, which would just emit some
    > small code to show in the designer. This would solve
    > your problem.
    >
    > Look here:
    > http://msdn.microsoft.com/asp.net/d...s/dnaspp/html/aspnet-adddesigntimesupport.asp
    >
    > --
    >
    > Jos
    >
    >
    >
     
    Magne Ryholt, Oct 17, 2004
    #3
  4. Magne Ryholt

    Jos Guest

    Magne Ryholt wrote:
    > Thanks for your answer
    > I beleive your answer indicates to emit some HTML for showing the
    > control in
    > design time, but still it will occupy space in the form designer ?


    Not if you make it emit an empty string.

    --

    Jos
     
    Jos, Oct 17, 2004
    #4
  5. Magne Ryholt

    Magne Ryholt Guest

    But then it is so difficult to find it on the design surface
    "Jos" <> wrote in message
    news:...
    > Magne Ryholt wrote:
    >> Thanks for your answer
    >> I beleive your answer indicates to emit some HTML for showing the
    >> control in
    >> design time, but still it will occupy space in the form designer ?

    >
    > Not if you make it emit an empty string.
    >
    > --
    >
    > Jos
    >
    >
    >
     
    Magne Ryholt, Oct 17, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    732
  2. Karim Ali
    Replies:
    1
    Views:
    284
    James Stroud
    May 24, 2007
  3. Rajat
    Replies:
    3
    Views:
    719
    Jorgen Grahn
    Jan 8, 2010
  4. VYAS ASHISH M-NTB837
    Replies:
    2
    Views:
    580
    Jan Kaliszewski
    Jan 7, 2010
  5. Leyla

    Web user control - custom web control - java script.

    Leyla, May 1, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    132
    Leyla
    May 1, 2006
Loading...

Share This Page