Webcontrol Designer Awareness...

Discussion in 'ASP .Net Web Controls' started by Weston Weems, Jul 5, 2005.

  1. Weston Weems

    Weston Weems Guest

    I've got a webcontrol that has some methods that fire off rendering
    javascript to the page etc, that shouldnt be fired off if loaded up in a
    designer.

    I'd like to know if there is some sort of conditional block I can use to
    prevent this code from being run...

    Something like

    MyWebControl(){

    if(!IsDesigner){
    registerJs();
    }

    }

    Thanks in advance
     
    Weston Weems, Jul 5, 2005
    #1
    1. Advertising

  2. You can override the GetDesignTimeHTML method. This is where you specify
    what is rendered in the designer. As opposed to RenderContents which gets
    your application output.

    What code are you using to render the script?
    --
    Staff Consultant II
    Enterprise Web Services
    Cardinal Solutions Group

    Future Business Model
    Loan Origination Services
    National City Mortgage


    "Weston Weems" wrote:

    > I've got a webcontrol that has some methods that fire off rendering
    > javascript to the page etc, that shouldnt be fired off if loaded up in a
    > designer.
    >
    > I'd like to know if there is some sort of conditional block I can use to
    > prevent this code from being run...
    >
    > Something like
    >
    > MyWebControl(){
    >
    > if(!IsDesigner){
    > registerJs();
    > }
    >
    > }
    >
    > Thanks in advance
    >
    >
    >
     
    Michael Baltic, Jul 6, 2005
    #2
    1. Advertising

  3. If you are in a webcontrol, you can use this code:

    public bool IsDesign
    {
    get
    {
    if((this.Site != null && this.Site.DesignMode) || (this.Page != null &&
    this.Page.Site != null && this.Page.Site.DesignMode))
    return true;
    return false;
    }
    }
    --
    Staff Consultant II
    Enterprise Web Services
    Cardinal Solutions Group

    Future Business Model
    Loan Origination Services
    National City Mortgage


    "Weston Weems" wrote:

    > I've got a webcontrol that has some methods that fire off rendering
    > javascript to the page etc, that shouldnt be fired off if loaded up in a
    > designer.
    >
    > I'd like to know if there is some sort of conditional block I can use to
    > prevent this code from being run...
    >
    > Something like
    >
    > MyWebControl(){
    >
    > if(!IsDesigner){
    > registerJs();
    > }
    >
    > }
    >
    > Thanks in advance
    >
    >
    >
     
    Michael Baltic, Jul 6, 2005
    #3
    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. MattB
    Replies:
    3
    Views:
    320
    Teemu Keiski
    Jan 22, 2004
  2. Martin M.
    Replies:
    4
    Views:
    360
    Simon Brunning
    Dec 15, 2005
  3. adeelmahmood
    Replies:
    11
    Views:
    934
    Alex Hunsley
    Feb 15, 2007
  4. makarand
    Replies:
    0
    Views:
    494
    makarand
    Jul 7, 2008
  5. Mohamed Yousef
    Replies:
    0
    Views:
    222
    Mohamed Yousef
    Aug 23, 2008
Loading...

Share This Page