Click here to Skip to main content
15,902,299 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionASP.net MasterPages [modified] Pin
WebMaster9-Jul-06 13:13
WebMaster9-Jul-06 13:13 
QuestionQuery Strings and Frames Pin
JBL_Andon9-Jul-06 7:59
JBL_Andon9-Jul-06 7:59 
AnswerRe: Query Strings and Frames Pin
Guffa9-Jul-06 10:39
Guffa9-Jul-06 10:39 
Questionproved extra info for the membership? Pin
Snowjim9-Jul-06 6:56
Snowjim9-Jul-06 6:56 
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 
hi all,

i have created an custom server control that is rendered, i.e., not a composite control that is built in CreateChildControls(). My control extends WebControl and i have wired up the ClientScript.GetPostBackEventReference() but this doesnt work if javascript is disabled, obviously.

so i also wired up the Click event of the buttons in my control as a failsafe, but they never fire. can anyone please help with this.

the control is huge, so i will try and post the relevant code below.

the control is a message box and i only need to be concerned with the button click events.

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);
        button.Click += new EventHandler(Button_Click);
      }
    }
#region ButtonClicked event

    protected void Button_Click(object sender, EventArgs e)
    {
      OnButtonClicked(new ButtonClickedArgs((Button)sender));
    }

    public delegate void ButtonClickedHandler(MessageBox sender, ButtonClickedArgs e);
    [
     Description("Fired when a button is clicked within the Message Box"),
     Category("Button")
    ]
    public event ButtonClickedHandler ButtonClicked;

    /// <summary>
    /// Fires the MessageBoxButtonClicked event
    /// </summary>
    protected void OnButtonClicked(ButtonClickedArgs e)
    {
      if (ButtonClicked != null)
      {
        ButtonClicked(this, e);

        // hide the message box
        this.Visible = false;
      }
    }

    #endregion
    
    #region IPostBackEventHandler Members

    public void RaisePostBackEvent(string eventArgument)
    {
      bool found = false;
      Button button = null;
      int i = 0;

      while (i < Buttons.Count && !found)
      {
        Button b = Buttons[i];
        if (b.Text == eventArgument)
        {
          found = true;
          button = b;
        }
        i++;
      }
      if (button != null)
      {
        OnButtonClicked(new ButtonClickedArgs(button));
      }
    }

    #endregion


kind regards,
g00fy
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 
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 

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.