Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > autopostback on dropdownlist

Reply
Thread Tools

autopostback on dropdownlist

 
 
TJS
Guest
Posts: n/a
 
      06-14-2005
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()
....


 
Reply With Quote
 
 
 
 
=?Utf-8?B?Y3Vpa2U1MTk=?=
Guest
Posts: n/a
 
      06-14-2005
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()
> ....
>
>
>

 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      06-14-2005
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()
> ....
>
>



 
Reply With Quote
 
TJS
Guest
Posts: n/a
 
      06-14-2005
here is the answer which was found to work

writer.AddAttribute(HtmlTextWriterAttribute.Onchan ge,
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()
> ....
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dropdownlist value not persisting after autopostback Daniel Doyle ASP .Net 1 06-25-2004 12:00 PM
DropDownList (with AutoPostBack) in a DataGrid Jaleel Syed via .NET 247 ASP .Net 0 04-23-2004 04:56 AM
Re: DropDownlist OnSelectionChanged and AutoPostback = False S. Justin Gengo ASP .Net 0 08-15-2003 06:27 PM
Re: DropDownlist OnSelectionChanged and AutoPostback = False George Durzi ASP .Net 0 08-15-2003 03:10 PM
DropDownList and AutoPostback -- default item Null ASP .Net 1 08-05-2003 03:28 PM



Advertisments
 



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