Click here to Skip to main content
15,879,096 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionCompiling 1.1 and 2.0 version of same library? Pin
rmatejka9-Jul-06 5:03
rmatejka9-Jul-06 5:03 
AnswerRe: Compiling 1.1 and 2.0 version of same library? Pin
RichardGrimmer11-Jul-06 5:26
RichardGrimmer11-Jul-06 5:26 
GeneralRe: Compiling 1.1 and 2.0 version of same library? Pin
rmatejka11-Jul-06 5:56
rmatejka11-Jul-06 5:56 
Questionevent in custom control [modified] Pin
g00fyman9-Jul-06 3:51
g00fyman9-Jul-06 3:51 
AnswerRe: event in custom control Pin
minhpc_bk9-Jul-06 16:45
minhpc_bk9-Jul-06 16:45 
GeneralRe: event in custom control Pin
g00fyman9-Jul-06 16:52
g00fyman9-Jul-06 16:52 
GeneralRe: event in custom control Pin
minhpc_bk9-Jul-06 17:13
minhpc_bk9-Jul-06 17:13 
GeneralRe: event in custom control Pin
g00fyman9-Jul-06 17:26
g00fyman9-Jul-06 17:26 
the buttons are decalred in a button collection.

initially the button collection is instantiated like this
private ButtonCollection m_Buttons = new ButtonCollection();
    [
     PersistenceMode(PersistenceMode.InnerProperty),
     DesignerSerializationVisibility(DesignerSerializationVisibility.Visible),
     Editor(typeof(ButtonCollectionEditor), typeof(UITypeEditor)),
     Category("Message Box"),
     Description("The buttons that will appear on the Message Box"),
     NotifyParentProperty(true),
     RefreshProperties(RefreshProperties.All),
     Bindable(true)
    ]
    public ButtonCollection Buttons
    {
      get { return m_Buttons; }
    }


in the MessageBox class. There is also an enum to designate a predifned set of buttons that works like this

private MessageBoxType m_MessageBoxButtons = MessageBoxType.YesNoCancel;
    [
     Category("Message Box"),
     Description("The pre-defined type of Message Box you want to start with."),
     DefaultValue(MessageBoxType.YesNoCancel),
     Bindable(true),
     NotifyParentProperty(true)
    ]
    public MessageBoxType MessageBoxButtons
    {
      get { return m_MessageBoxButtons; }
      set
      {
        m_MessageBoxButtons = value;

        Button[] buttons = null;
        Button button = null;

        switch (m_MessageBoxButtons)
        {
          case MessageBoxType.YesNoCancel:

            buttons = new Button[3];

            button = new Button();
            button.ID = "YesButton_" + DateTime.Now.Millisecond;
            button.Text = "Yes";
            buttons[0] = button;

            button = new Button();
            button.ID = "NoButton_" + DateTime.Now.Millisecond;
            button.Text = "No";
            buttons[1] = button;

            button = new Button();
            button.ID = "CancelButton_" + DateTime.Now.Millisecond;
            button.Text = "Cancel";
            buttons[2] = button;

            m_Buttons = new ButtonCollection(buttons);

            break;

          case MessageBoxType.YesNoAbort:

            buttons = new Button[3];

            button = new Button();
            button.ID = "YesButton_" + DateTime.Now.Millisecond;
            button.Text = "Yes";
            buttons[0] = button;

            button = new Button();
            button.ID = "NoButton_" + DateTime.Now.Millisecond;
            button.Text = "No";
            buttons[1] = button;

            button = new Button();
            button.ID = "AbortButton_" + DateTime.Now.Millisecond;
            button.Text = "Abort";
            buttons[2] = button;

            m_Buttons = new ButtonCollection(buttons);

            break;

          case MessageBoxType.Custom:

            Buttons.Clear();
            break;
        }
      }
    }


then in OnInit() i wire up the events like this, i also tried wiring up the event for the buttins during render, but that didnt work either.

protected override void OnInit(EventArgs e)
    {
      if (Draggable)
      {
        Page.ClientScript.RegisterClientScriptInclude(
          this.GetType(), "DragScript", Page.ClientScript.GetWebResourceUrl(this.GetType(),
           "WebMessageBox.Resources.DragScript.js"));
      }
      RenderEmbeddedStyleSheet(null);

      foreach (Button button in Buttons)
      {
        button.Attributes["onclick"] = Page.ClientScript.GetPostBackEventReference(this, button.Text.Trim());
        button.Click += new EventHandler(Button_Click);
      }
    }


the ButtonCollection class extends CollectionBase and overrides the standard functions (add, this[int], delete, clear etc) so it is strongly typed.

kind regards,
g00fy
GeneralRe: event in custom control Pin
minhpc_bk9-Jul-06 18:24
minhpc_bk9-Jul-06 18:24 
GeneralRe: event in custom control Pin
g00fyman9-Jul-06 18:41
g00fyman9-Jul-06 18:41 
GeneralRe: event in custom control Pin
g00fyman9-Jul-06 19:05
g00fyman9-Jul-06 19:05 
GeneralRe: event in custom control Pin
g00fyman9-Jul-06 19:20
g00fyman9-Jul-06 19:20 
GeneralRe: event in custom control Pin
minhpc_bk9-Jul-06 19:32
minhpc_bk9-Jul-06 19:32 
GeneralRe: event in custom control [modified] Pin
g00fyman9-Jul-06 20:59
g00fyman9-Jul-06 20:59 
GeneralRe: event in custom control Pin
minhpc_bk10-Jul-06 17:11
minhpc_bk10-Jul-06 17:11 
GeneralRe: event in custom control Pin
g00fyman10-Jul-06 17:42
g00fyman10-Jul-06 17:42 
QuestionWeb.cofig error [modified] Pin
madalluge9-Jul-06 3:25
madalluge9-Jul-06 3:25 
AnswerRe: Web.cofig error Pin
Guffa9-Jul-06 5:33
Guffa9-Jul-06 5:33 
QuestionDebugging Problem Pin
AliAmjad9-Jul-06 3:05
AliAmjad9-Jul-06 3:05 
AnswerRe: Debugging Problem Pin
Subrahmanyam K9-Jul-06 18:19
Subrahmanyam K9-Jul-06 18:19 
QuestionDisplaying IE Popup before download Pin
VenkataRamana.Gali9-Jul-06 1:09
VenkataRamana.Gali9-Jul-06 1:09 
QuestionHow and Where to store the data Pin
Pentellcc8-Jul-06 13:35
Pentellcc8-Jul-06 13:35 
AnswerRe: How and Where to store the data Pin
Guffa8-Jul-06 23:20
Guffa8-Jul-06 23:20 
GeneralRe: How and Where to store the data Pin
Pentellcc9-Jul-06 7:27
Pentellcc9-Jul-06 7:27 
AnswerRe: How and Where to store the data Pin
Guffa9-Jul-06 10:24
Guffa9-Jul-06 10:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.