autopostback on dropdownlist

T

TJS

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()
....
 
G

Guest

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.
}
}
 
E

Eliyahu Goldin

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
 
T

TJS

here is the answer which was found to work

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top