Codegeneration in custom webcontrols

Discussion in 'ASP .Net Building Controls' started by Patrik Lindholm, Oct 10, 2003.

  1. Hi!

    I'm fiddling around with CodeDom and codegenration.
    I've looked at some samples which adds comments
    and a methodcall but I want to do more.

    I´ve created a control with a linkbuttoncollection where
    you can add and remove linkbuttons as you like,
    change properties in the collectioneditor for
    each linkbutton. There is a custom property
    which I've called "RedirectToPage" where
    you can select a page to redirect to when you
    click the linkbutton.
    The control also have an event called "ItemClick"
    which i want to add code for when I drop the control
    onto a webform.
    The code shoul look something like the code below except for the comments

    // Code sample
    // In InitializeComponent
    MyMenuControl myMenuControl1

    myMenuControl1.ItemClick += new
    ItemClickHandler(this.myMenuControl_ItemClick);
    // End InitializeComponent

    // Eventhandler
    private void myMenuControl_ItemClick(object sender, EventArgs e)
    {
    if("MyMenuControlItem" = = sender.GetType().ToString())
    {
    MyMenuControlItem mItem = (MyMenuControlItem)sender;

    Response.Redirect(mItem.RedirectToPage);
    }
    }

    Is it possible to do this.

    Thank you in advance.

    // Patrik
     
    Patrik Lindholm, Oct 10, 2003
    #1
    1. Advertising

  2. "Patrik Lindholm" <> wrote in message
    news:...
    > Hi!
    >
    > I'm fiddling around with CodeDom and codegenration.
    > I've looked at some samples which adds comments
    > and a methodcall but I want to do more.
    >
    > I´ve created a control with a linkbuttoncollection where
    > you can add and remove linkbuttons as you like,
    > change properties in the collectioneditor for
    > each linkbutton. There is a custom property
    > which I've called "RedirectToPage" where
    > you can select a page to redirect to when you
    > click the linkbutton.
    > The control also have an event called "ItemClick"
    > which i want to add code for when I drop the control
    > onto a webform.
    > The code shoul look something like the code below except for the comments
    >
    > // Code sample
    > // In InitializeComponent
    > MyMenuControl myMenuControl1
    >
    > myMenuControl1.ItemClick += new
    > ItemClickHandler(this.myMenuControl_ItemClick);
    > // End InitializeComponent
    >
    > // Eventhandler
    > private void myMenuControl_ItemClick(object sender, EventArgs e)
    > {
    > if("MyMenuControlItem" = = sender.GetType().ToString())
    > {
    > MyMenuControlItem mItem = (MyMenuControlItem)sender;
    >
    > Response.Redirect(mItem.RedirectToPage);
    > }
    > }
    >
    > Is it possible to do this.


    I haven't previously seen an example of using CodeDOM with web forms
    controls, which persist their properties to the .aspx file and not to code
    like Windows Forms controls do. Can you point me to an example of using
    CodeDOM this way? It would be very useful to me.
    --
    John Saunders
    Internet Engineer
     
    John Saunders, Oct 10, 2003
    #2
    1. Advertising

  3. Sorry I have not seen any examples using CodeDom in WebForm pages only in a
    WinForms control example

    Link to that example:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/custcodegen.asp

    On the page there are a link to a sampleproject


    // Patrik

    "John Saunders" <john.saunders at surfcontrol.com> wrote in message
    news:%...
    > "Patrik Lindholm" <> wrote in message
    > news:...
    > > Hi!
    > >
    > > I'm fiddling around with CodeDom and codegenration.
    > > I've looked at some samples which adds comments
    > > and a methodcall but I want to do more.
    > >
    > > I´ve created a control with a linkbuttoncollection where
    > > you can add and remove linkbuttons as you like,
    > > change properties in the collectioneditor for
    > > each linkbutton. There is a custom property
    > > which I've called "RedirectToPage" where
    > > you can select a page to redirect to when you
    > > click the linkbutton.
    > > The control also have an event called "ItemClick"
    > > which i want to add code for when I drop the control
    > > onto a webform.
    > > The code shoul look something like the code below except for the

    comments
    > >
    > > // Code sample
    > > // In InitializeComponent
    > > MyMenuControl myMenuControl1
    > >
    > > myMenuControl1.ItemClick += new
    > > ItemClickHandler(this.myMenuControl_ItemClick);
    > > // End InitializeComponent
    > >
    > > // Eventhandler
    > > private void myMenuControl_ItemClick(object sender, EventArgs e)
    > > {
    > > if("MyMenuControlItem" = = sender.GetType().ToString())
    > > {
    > > MyMenuControlItem mItem = (MyMenuControlItem)sender;
    > >
    > > Response.Redirect(mItem.RedirectToPage);
    > > }
    > > }
    > >
    > > Is it possible to do this.

    >
    > I haven't previously seen an example of using CodeDOM with web forms
    > controls, which persist their properties to the .aspx file and not to code
    > like Windows Forms controls do. Can you point me to an example of using
    > CodeDOM this way? It would be very useful to me.
    > --
    > John Saunders
    > Internet Engineer
    >
    >
    >
     
    Patrik Lindholm, Oct 10, 2003
    #3
  4. Patrik Lindholm

    Andy Smith Guest

    the codedom isn't going to be very useful with webforms. that's just not the
    serialization model. I suggest you find another way to do what you want.

    __
    Andy Smith

    "Patrik Lindholm" <> wrote in message
    news:#...
    >
    > Sorry I have not seen any examples using CodeDom in WebForm pages only in

    a
    > WinForms control example
    >
    > Link to that example:
    >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/custcodegen.asp
    >
    > On the page there are a link to a sampleproject
    >
    >
    > // Patrik
    >
    > "John Saunders" <john.saunders at surfcontrol.com> wrote in message
    > news:%...
    > > "Patrik Lindholm" <> wrote in message
    > > news:...
    > > > Hi!
    > > >
    > > > I'm fiddling around with CodeDom and codegenration.
    > > > I've looked at some samples which adds comments
    > > > and a methodcall but I want to do more.
    > > >
    > > > I´ve created a control with a linkbuttoncollection where
    > > > you can add and remove linkbuttons as you like,
    > > > change properties in the collectioneditor for
    > > > each linkbutton. There is a custom property
    > > > which I've called "RedirectToPage" where
    > > > you can select a page to redirect to when you
    > > > click the linkbutton.
    > > > The control also have an event called "ItemClick"
    > > > which i want to add code for when I drop the control
    > > > onto a webform.
    > > > The code shoul look something like the code below except for the

    > comments
    > > >
    > > > // Code sample
    > > > // In InitializeComponent
    > > > MyMenuControl myMenuControl1
    > > >
    > > > myMenuControl1.ItemClick += new
    > > > ItemClickHandler(this.myMenuControl_ItemClick);
    > > > // End InitializeComponent
    > > >
    > > > // Eventhandler
    > > > private void myMenuControl_ItemClick(object sender, EventArgs e)
    > > > {
    > > > if("MyMenuControlItem" = = sender.GetType().ToString())
    > > > {
    > > > MyMenuControlItem mItem = (MyMenuControlItem)sender;
    > > >
    > > > Response.Redirect(mItem.RedirectToPage);
    > > > }
    > > > }
    > > >
    > > > Is it possible to do this.

    > >
    > > I haven't previously seen an example of using CodeDOM with web forms
    > > controls, which persist their properties to the .aspx file and not to

    code
    > > like Windows Forms controls do. Can you point me to an example of using
    > > CodeDOM this way? It would be very useful to me.
    > > --
    > > John Saunders
    > > Internet Engineer
    > >
    > >
    > >

    >
    >
     
    Andy Smith, Oct 10, 2003
    #4
  5. Patrik Lindholm

    Genich Guest

    A designer uses the services from the
    System.ComponentModel.Design.Serialization.IDesignerSerializationManager to
    serialize components into code. Visual Studio .NET, uses the
    System.ComponentModel.Design.Serialization.CodeDomSerializer to generate
    code for property values of components on a designer.

    An object can tell the designer framework that it will
    use a custom serializer for saving its state. This is done via the
    System.ComponentModel.Design.Serialization.DesignerSerializerAttribute.

    Visual Studio .NET only understands one type of base designer serializer,
    which is an
    abstract class named
    System.ComponentModel.Design.Serialization.CodeDomSerializer.



    "Andy Smith" <> wrote in message
    news:#...
    > the codedom isn't going to be very useful with webforms. that's just not

    the
    > serialization model. I suggest you find another way to do what you want.
    >
    > __
    > Andy Smith
    >
    > "Patrik Lindholm" <> wrote in message
    > news:#...
    > >
    > > Sorry I have not seen any examples using CodeDom in WebForm pages only

    in
    > a
    > > WinForms control example
    > >
    > > Link to that example:
    > >

    >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
    ml/custcodegen.asp
    > >
    > > On the page there are a link to a sampleproject
    > >
    > >
    > > // Patrik
    > >
    > > "John Saunders" <john.saunders at surfcontrol.com> wrote in message
    > > news:%...
    > > > "Patrik Lindholm" <> wrote in message
    > > > news:...
    > > > > Hi!
    > > > >
    > > > > I'm fiddling around with CodeDom and codegenration.
    > > > > I've looked at some samples which adds comments
    > > > > and a methodcall but I want to do more.
    > > > >
    > > > > I´ve created a control with a linkbuttoncollection where
    > > > > you can add and remove linkbuttons as you like,
    > > > > change properties in the collectioneditor for
    > > > > each linkbutton. There is a custom property
    > > > > which I've called "RedirectToPage" where
    > > > > you can select a page to redirect to when you
    > > > > click the linkbutton.
    > > > > The control also have an event called "ItemClick"
    > > > > which i want to add code for when I drop the control
    > > > > onto a webform.
    > > > > The code shoul look something like the code below except for the

    > > comments
    > > > >
    > > > > // Code sample
    > > > > // In InitializeComponent
    > > > > MyMenuControl myMenuControl1
    > > > >
    > > > > myMenuControl1.ItemClick += new
    > > > > ItemClickHandler(this.myMenuControl_ItemClick);
    > > > > // End InitializeComponent
    > > > >
    > > > > // Eventhandler
    > > > > private void myMenuControl_ItemClick(object sender, EventArgs e)
    > > > > {
    > > > > if("MyMenuControlItem" = = sender.GetType().ToString())
    > > > > {
    > > > > MyMenuControlItem mItem = (MyMenuControlItem)sender;
    > > > >
    > > > > Response.Redirect(mItem.RedirectToPage);
    > > > > }
    > > > > }
    > > > >
    > > > > Is it possible to do this.
    > > >
    > > > I haven't previously seen an example of using CodeDOM with web forms
    > > > controls, which persist their properties to the .aspx file and not to

    > code
    > > > like Windows Forms controls do. Can you point me to an example of

    using
    > > > CodeDOM this way? It would be very useful to me.
    > > > --
    > > > John Saunders
    > > > Internet Engineer
    > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Genich, Oct 13, 2003
    #5
  6. "Genich" <> wrote in message
    news:S5nib.745109$YN5.693809@sccrnsc01...
    > A designer uses the services from the
    > System.ComponentModel.Design.Serialization.IDesignerSerializationManager

    to
    > serialize components into code. Visual Studio .NET, uses the
    > System.ComponentModel.Design.Serialization.CodeDomSerializer to generate
    > code for property values of components on a designer.
    >
    > An object can tell the designer framework that it will
    > use a custom serializer for saving its state. This is done via the
    > System.ComponentModel.Design.Serialization.DesignerSerializerAttribute.
    >
    > Visual Studio .NET only understands one type of base designer serializer,
    > which is an
    > abstract class named
    > System.ComponentModel.Design.Serialization.CodeDomSerializer.


    This is very interesting. Do you have an example of using CodeDomSerializer
    in a Web Forms designer?
    --
    John Saunders
    Internet Engineer



    > "Andy Smith" <> wrote in message
    > news:#...
    > > the codedom isn't going to be very useful with webforms. that's just not

    > the
    > > serialization model. I suggest you find another way to do what you want.
    > >
    > > __
    > > Andy Smith
    > >
    > > "Patrik Lindholm" <> wrote in message
    > > news:#...
    > > >
    > > > Sorry I have not seen any examples using CodeDom in WebForm pages only

    > in
    > > a
    > > > WinForms control example
    > > >
    > > > Link to that example:
    > > >

    > >

    >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/ht
    > ml/custcodegen.asp
    > > >
    > > > On the page there are a link to a sampleproject
    > > >
    > > >
    > > > // Patrik
    > > >
    > > > "John Saunders" <john.saunders at surfcontrol.com> wrote in message
    > > > news:%...
    > > > > "Patrik Lindholm" <> wrote in message
    > > > > news:...
    > > > > > Hi!
    > > > > >
    > > > > > I'm fiddling around with CodeDom and codegenration.
    > > > > > I've looked at some samples which adds comments
    > > > > > and a methodcall but I want to do more.
    > > > > >
    > > > > > I´ve created a control with a linkbuttoncollection where
    > > > > > you can add and remove linkbuttons as you like,
    > > > > > change properties in the collectioneditor for
    > > > > > each linkbutton. There is a custom property
    > > > > > which I've called "RedirectToPage" where
    > > > > > you can select a page to redirect to when you
    > > > > > click the linkbutton.
    > > > > > The control also have an event called "ItemClick"
    > > > > > which i want to add code for when I drop the control
    > > > > > onto a webform.
    > > > > > The code shoul look something like the code below except for the
    > > > comments
    > > > > >
    > > > > > // Code sample
    > > > > > // In InitializeComponent
    > > > > > MyMenuControl myMenuControl1
    > > > > >
    > > > > > myMenuControl1.ItemClick += new
    > > > > > ItemClickHandler(this.myMenuControl_ItemClick);
    > > > > > // End InitializeComponent
    > > > > >
    > > > > > // Eventhandler
    > > > > > private void myMenuControl_ItemClick(object sender, EventArgs e)
    > > > > > {
    > > > > > if("MyMenuControlItem" = = sender.GetType().ToString())
    > > > > > {
    > > > > > MyMenuControlItem mItem =

    (MyMenuControlItem)sender;
    > > > > >
    > > > > > Response.Redirect(mItem.RedirectToPage);
    > > > > > }
    > > > > > }
    > > > > >
    > > > > > Is it possible to do this.
    > > > >
    > > > > I haven't previously seen an example of using CodeDOM with web forms
    > > > > controls, which persist their properties to the .aspx file and not

    to
    > > code
    > > > > like Windows Forms controls do. Can you point me to an example of

    > using
    > > > > CodeDOM this way? It would be very useful to me.
    > > > > --
    > > > > John Saunders
    > > > > Internet Engineer
    > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    John Saunders, Oct 13, 2003
    #6
    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. Alexander Widera

    2 custom webcontrols with postback problem

    Alexander Widera, Mar 27, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    341
  2. Mantorok

    Custom WebControls and images

    Mantorok, Aug 10, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    348
    =?Utf-8?B?RGF2aWQgSmVzc2Vl?=
    Aug 10, 2006
  3. DataDirect Technologies
    Replies:
    0
    Views:
    381
    DataDirect Technologies
    May 6, 2008
  4. Peter Mueller
    Replies:
    0
    Views:
    319
    Peter Mueller
    Nov 7, 2010
  5. Peter Lykkegaard

    Custom Webcontrols, VS EDI support and intellisense?

    Peter Lykkegaard, Aug 8, 2004, in forum: ASP .Net Building Controls
    Replies:
    4
    Views:
    157
    Peter Lykkegaard
    Aug 9, 2004
Loading...

Share This Page