autopostback on dropdownlist

Discussion in 'ASP .Net' started by TJS, Jun 14, 2005.

  1. TJS

    TJS Guest

    I am rendering a dropdownlist from HTMLTextWriter, how do I specify to
    enable autopostback ?

    '=========================================
    ....
    writer.AddAttribute(HtmlTextWriterAttribute.Id, "xx")
    writer.AddAttribute(HtmlTextWriterAttribute.Name, "xx")
    writer.RenderBeginTag(HtmlTextWriterTag.Select)

    writer.AddAttribute( HtmlTextWriterAttribute.Value, "-1" )
    writer.RenderBeginTag(HtmlTextWriterTag.Option)
    writer.Write( HttpUtility.HtmlEncode("-- All --") )
    writer.RenderEndTag()

    writer.RenderEndTag()
    ....
    TJS, Jun 14, 2005
    #1
    1. Advertising

  2. You can implement IPostBackDataHandler interface for your purpose.For example:
    class MyDropDownList:WebControl,IPostBackDataHandler{
    // below,your must implement IPostBackDataHandler's method.
    bool LoadPostData(string postDataKey, NameValueCollection postCollection){
    // check postback data here
    }

    void RaisePostDataChangedEvent(){
    // raise your event here.
    }
    }

    "TJS" wrote:

    > I am rendering a dropdownlist from HTMLTextWriter, how do I specify to
    > enable autopostback ?
    >
    > '=========================================
    > ....
    > writer.AddAttribute(HtmlTextWriterAttribute.Id, "xx")
    > writer.AddAttribute(HtmlTextWriterAttribute.Name, "xx")
    > writer.RenderBeginTag(HtmlTextWriterTag.Select)
    >
    > writer.AddAttribute( HtmlTextWriterAttribute.Value, "-1" )
    > writer.RenderBeginTag(HtmlTextWriterTag.Option)
    > writer.Write( HttpUtility.HtmlEncode("-- All --") )
    > writer.RenderEndTag()
    >
    > writer.RenderEndTag()
    > ....
    >
    >
    >
    =?Utf-8?B?Y3Vpa2U1MTk=?=, Jun 14, 2005
    #2
    1. Advertising

  3. Enabling autopostback is a server-side task. Asp.net knows how to translate
    "AutoPostBack=true" instruction to a set of client-side commands supported
    on the server-side. HtmlTextWriter produces pure client code. To reproduce
    autopostback behavior on this level, you need to know what to put into the
    page output and what to handle on server side. Don't reinvent wheel, just
    use normal asp:dropdownlist.

    Eliyahu

    "TJS" <> wrote in message
    news:%...
    > I am rendering a dropdownlist from HTMLTextWriter, how do I specify to
    > enable autopostback ?
    >
    > '=========================================
    > ...
    > writer.AddAttribute(HtmlTextWriterAttribute.Id, "xx")
    > writer.AddAttribute(HtmlTextWriterAttribute.Name, "xx")
    > writer.RenderBeginTag(HtmlTextWriterTag.Select)
    >
    > writer.AddAttribute( HtmlTextWriterAttribute.Value, "-1" )
    > writer.RenderBeginTag(HtmlTextWriterTag.Option)
    > writer.Write( HttpUtility.HtmlEncode("-- All --") )
    > writer.RenderEndTag()
    >
    > writer.RenderEndTag()
    > ....
    >
    >
    Eliyahu Goldin, Jun 14, 2005
    #3
  4. TJS

    TJS Guest

    here is the answer which was found to work

    writer.AddAttribute(HtmlTextWriterAttribute.Onchange,
    Page.GetPostBackEventReference(Me))



    "TJS" <> wrote in message
    news:%...
    >I am rendering a dropdownlist from HTMLTextWriter, how do I specify to
    >enable autopostback ?
    >
    > '=========================================
    > ...
    > writer.AddAttribute(HtmlTextWriterAttribute.Id, "xx")
    > writer.AddAttribute(HtmlTextWriterAttribute.Name, "xx")
    > writer.RenderBeginTag(HtmlTextWriterTag.Select)
    >
    > writer.AddAttribute( HtmlTextWriterAttribute.Value, "-1" )
    > writer.RenderBeginTag(HtmlTextWriterTag.Option)
    > writer.Write( HttpUtility.HtmlEncode("-- All --") )
    > writer.RenderEndTag()
    >
    > writer.RenderEndTag()
    > ....
    >
    TJS, Jun 14, 2005
    #4
    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. Null
    Replies:
    1
    Views:
    577
    S. Justin Gengo
    Aug 5, 2003
  2. George Durzi
    Replies:
    0
    Views:
    724
    George Durzi
    Aug 15, 2003
  3. S. Justin Gengo
    Replies:
    0
    Views:
    3,143
    S. Justin Gengo
    Aug 15, 2003
  4. Jaleel Syed via .NET 247

    DropDownList (with AutoPostBack) in a DataGrid

    Jaleel Syed via .NET 247, Apr 23, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    513
    Jaleel Syed via .NET 247
    Apr 23, 2004
  5. Daniel Doyle
    Replies:
    1
    Views:
    610
    Steve Caliendo
    Jun 25, 2004
Loading...

Share This Page