[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

ggeshev

3/21/2008 5:32:00 PM

Hello!

I am building a Webcontrol.

public class MyCustomControl : WebControl, IPostBackEventHandler,
IPostBackDataHandler {
.......

void IPostBackEventHandler.RaisePostBackEvent(string args)
{
RaisePostBackEvent(args);
}

protected virtual void RaisePostBackEvent(string args) {

}


bool IPostBackDataHandler.LoadPostData(string postDataKey,
NameValueCollection values)
{
return LoadPostData(postDataKey, values);
}

protected virtual bool LoadPostData(string postDataKey,
NameValueCollection values)
{
return true;
}

void IPostBackDataHandler.RaisePostDataChangedEvent()
{
RaisePostDataChangedEvent();
}

protected virtual void RaisePostDataChangedEvent()
{

}

}


The problem is - Nevertheless I implement IPostBackEventHandlerand
IPostBackDataHandler , methods RaisePostBackEvent, LoadPostData and
RaisePostDataChangedEvent are never called.

Why is so?


2 Answers

Tony

3/26/2008 4:19:00 PM

0

I think IPostBackEventHandler only work when you implement in Page control.

"ggeshev" <ggeshev@tonegan.bg> wrote in message
news:%23YiTvm3iIHA.944@TK2MSFTNGP05.phx.gbl...
> Hello!
>
> I am building a Webcontrol.
>
> public class MyCustomControl : WebControl, IPostBackEventHandler,
> IPostBackDataHandler {
> .......
>
> void IPostBackEventHandler.RaisePostBackEvent(string args)
> {
> RaisePostBackEvent(args);
> }
>
> protected virtual void RaisePostBackEvent(string args) {
>
> }
>
>
> bool IPostBackDataHandler.LoadPostData(string postDataKey,
> NameValueCollection values)
> {
> return LoadPostData(postDataKey, values);
> }
>
> protected virtual bool LoadPostData(string postDataKey,
> NameValueCollection values)
> {
> return true;
> }
>
> void IPostBackDataHandler.RaisePostDataChangedEvent()
> {
> RaisePostDataChangedEvent();
> }
>
> protected virtual void RaisePostDataChangedEvent()
> {
>
> }
>
> }
>
>
> The problem is - Nevertheless I implement IPostBackEventHandlerand
> IPostBackDataHandler , methods RaisePostBackEvent, LoadPostData and
> RaisePostDataChangedEvent are never called.
>
> Why is so?
>

Brian Hartsock

4/22/2008 5:36:00 PM

0

On Mar 21, 1:32 pm, "ggeshev" <gges...@tonegan.bg> wrote:
> Hello!
>
> I am building a Webcontrol.
>
> public class MyCustomControl : WebControl, IPostBackEventHandler,
> IPostBackDataHandler {
> .......
>
> void IPostBackEventHandler.RaisePostBackEvent(string args)
> {
> RaisePostBackEvent(args);
> }
>
> protected virtual void RaisePostBackEvent(string args) {
>
> }
>
> bool IPostBackDataHandler.LoadPostData(string postDataKey,
> NameValueCollection values)
> {
> return LoadPostData(postDataKey, values);
> }
>
> protected virtual bool LoadPostData(string postDataKey,
> NameValueCollection values)
> {
> return true;
> }
>
> void IPostBackDataHandler.RaisePostDataChangedEvent()
> {
> RaisePostDataChangedEvent();
> }
>
> protected virtual void RaisePostDataChangedEvent()
> {
>
> }
>
> }
>
> The problem is - Nevertheless I implement IPostBackEventHandlerand
> IPostBackDataHandler , methods RaisePostBackEvent, LoadPostData and
> RaisePostDataChangedEvent are never called.
>
> Why is so?

Just implementing IPostBackDataHandler does nothing. You have to
register the control with the page. I usually do it in PreRender,
because if a page doesn't get rendered it can't handle post back
data. I don't think it really matters though. I think the same
applies to IPostBackEventHandler but I have never used that.

protected void Page_PreRender(object sender,
EventArgs e)
{
this.Page.RegisterRequiresPostBack(this);
}