handling event in server control

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default handling event in server control

    I am developing a special control, in fact it's a <td> tag
    however on click I need to submit somedata.
    so I write

    protected void Render(HtmlTextWriter htw)
    {
    // ......
    htw.Write("<td name='{0}' onclick='javascript:submit()'", UniqueID);
    // ..
    }
    and implement IPostBackEventHandler.
    however the method RaisePostBackEvent is never called (although the page is
    reload), any ideas ?


    Lloyd Dupont Guest

  2. Similar Questions and Discussions

    1. Handling a click event in custom server control
      I'm using VS 2005. I created a sample composite control with a textbox and a button. I'm having problems getting the button event. The control...
    2. Exception handling in server control development
      Dear Folks, in the server control development, i am throwing exception from the server control. i know that this cannot be handled in the page_load...
    3. Event handling in a Custom Tree control in ASP.Net and C3 web application
      I have a Tree control for displaying folders list for aparticular client in a Tree structure in a web application usingAsp.NET and C#. Now i want to...
    4. Adding dynamically user control (ASCX) into asp.net page and handling OnClick event
      Hi, I've been reading a lot's of Q&A on user controls but none seem to answer my question. Here it is. I need to add dynamically a user control,...
    5. Custom server Controls event handling (Parent/Child)
      Hi, Hello, I have a question regarding Custom server Controls event handling. The problem I am facing is, I have created 2 Controls say...
  3. #2

    Default Re: handling event in server control

    Yep

    The doPostback should contain the ID of the control as the first
    parameter. ASP.NET uses it to know which control to call. The second
    parameter usually used if more than one event exists.

    oSTR.Append(" onchange=\"__doPostBack('"+ this.ID +"','change')\"
    language=\"javascript\" \n");

    Natty Gur, CTO
    Dao2Com Ltd.
    28th Baruch Hirsch st. Bnei-Brak
    Israel , 51114

    Phone Numbers:
    Office: +972-(0)3-5786668
    Fax: +972-(0)3-5703475
    Mobile: +972-(0)58-888377

    Know the overall picture


    *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  4. #3

    Default Re: handling event in server control

    1. There is no value posted back for a td tag.
    2. Rather than just straight submitting the form, you might want to look
    into GetPostBackClientEvent method.

    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/[/url]
    frlrfsystemwebuipageclassgetpostbackclienteventtop ic.asp

    protected override void Render( HtmlTextWriter writer )
    {
    writer.AddAttribute( HtmlTextWriterAttribute.Name, UniqueID );
    writer.AddAttribute( HtmlTextWriterAttribute.OnClick,
    Page.GetClientPostBackEvent( this, "event args passed to your
    RaisePostBackEvent" );
    writer.RenderBeginTag( HtmlTextWriterTag.Td );
    writer.RenderEndTag();
    }

    You really should use the "helper" function provided by the page to handle
    the postback. By just calling submit, the form is just submitted, it
    doesn't know what button ( any other control) triggered the post back.

    HTH,

    bill

    "Lloyd Dupont" <lloyd@RemoveIfNotSpamming.galador.net> wrote in message
    news:#hjTvKRVDHA.1832@TK2MSFTNGP09.phx.gbl...
    > I am developing a special control, in fact it's a <td> tag
    > however on click I need to submit somedata.
    > so I write
    >
    > protected void Render(HtmlTextWriter htw)
    > {
    > // ......
    > htw.Write("<td name='{0}' onclick='javascript:submit()'", UniqueID);
    > // ..
    > }
    > and implement IPostBackEventHandler.
    > however the method RaisePostBackEvent is never called (although the page
    is
    > reload), any ideas ?
    >
    >

    William F. Robertson, Jr. Guest

  5. #4

    Default Re: handling event in server control

    I agree you, I was just looking for the information !
    You gave me the exactly accurate and useful answer !
    thansk the tip mate,

    Lloyd

    "William F. Robertson, Jr." <wfrobertson@kpmg.com> a écrit dans le message
    de news:eh3Hg3RVDHA.2340@TK2MSFTNGP10.phx.gbl...
    > 1. There is no value posted back for a td tag.
    > 2. Rather than just straight submitting the form, you might want to look
    > into GetPostBackClientEvent method.
    >
    >
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/[/url]
    > frlrfsystemwebuipageclassgetpostbackclienteventtop ic.asp
    >
    > protected override void Render( HtmlTextWriter writer )
    > {
    > writer.AddAttribute( HtmlTextWriterAttribute.Name, UniqueID );
    > writer.AddAttribute( HtmlTextWriterAttribute.OnClick,
    > Page.GetClientPostBackEvent( this, "event args passed to your
    > RaisePostBackEvent" );
    > writer.RenderBeginTag( HtmlTextWriterTag.Td );
    > writer.RenderEndTag();
    > }
    >
    > You really should use the "helper" function provided by the page to handle
    > the postback. By just calling submit, the form is just submitted, it
    > doesn't know what button ( any other control) triggered the post back.
    >
    > HTH,
    >
    > bill
    >
    > "Lloyd Dupont" <lloyd@RemoveIfNotSpamming.galador.net> wrote in message
    > news:#hjTvKRVDHA.1832@TK2MSFTNGP09.phx.gbl...
    > > I am developing a special control, in fact it's a <td> tag
    > > however on click I need to submit somedata.
    > > so I write
    > >
    > > protected void Render(HtmlTextWriter htw)
    > > {
    > > // ......
    > > htw.Write("<td name='{0}' onclick='javascript:submit()'", UniqueID);
    > > // ..
    > > }
    > > and implement IPostBackEventHandler.
    > > however the method RaisePostBackEvent is never called (although the page
    > is
    > > reload), any ideas ?
    > >
    > >
    >
    >

    Lloyd Dupont Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139