Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > IPostBackEventHandler not passing event argument

Reply
Thread Tools

IPostBackEventHandler not passing event argument

 
 
Mike
Guest
Posts: n/a
 
      07-22-2005
I have done this many times but for some reason it's not working, the raise
postback event fires but the eventArgument passed to it is empty. This is a
simple custom control that implements
IPostBackEventHandler

and I get the href for the a tag using

string href = this.Page.GetPostBackClientHyperlink(this,
tab.TabID.ToString());

In the trace for the postback the argumts is listed but it never arrives at



public void RaisePostBackEvent(string eventArgument)

{

this.Context.Trace.Write("SelectedID=" + eventArgument);

this.SelectedID = Convert.ToInt32(eventArgument);

}



This has got to be another one of the many wier asp.net behaviors, any
ideas...Thanks...


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      07-22-2005
Did you assign the UniqueID to the name attribute of the custom Control?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven

"Mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have done this many times but for some reason it's not working, the raise
> postback event fires but the eventArgument passed to it is empty. This is
> a
> simple custom control that implements
> IPostBackEventHandler
>
> and I get the href for the a tag using
>
> string href = this.Page.GetPostBackClientHyperlink(this,
> tab.TabID.ToString());
>
> In the trace for the postback the argumts is listed but it never arrives
> at
>
>
>
> public void RaisePostBackEvent(string eventArgument)
>
> {
>
> this.Context.Trace.Write("SelectedID=" + eventArgument);
>
> this.SelectedID = Convert.ToInt32(eventArgument);
>
> }
>
>
>
> This has got to be another one of the many wier asp.net behaviors, any
> ideas...Thanks...
>
>



 
Reply With Quote
 
 
 
 
Mike
Guest
Posts: n/a
 
      07-22-2005
Yes the unique id is set and RaisePostBackEvent is fired but eventArgument
passed to it is empty.

"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:uP9E%(E-Mail Removed)...
> Did you assign the UniqueID to the name attribute of the custom Control?
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> The sun never sets on
> the Kingdom of Heaven
>
> "Mike" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I have done this many times but for some reason it's not working, the

raise
> > postback event fires but the eventArgument passed to it is empty. This

is
> > a
> > simple custom control that implements
> > IPostBackEventHandler
> >
> > and I get the href for the a tag using
> >
> > string href = this.Page.GetPostBackClientHyperlink(this,
> > tab.TabID.ToString());
> >
> > In the trace for the postback the argumts is listed but it never arrives
> > at
> >
> >
> >
> > public void RaisePostBackEvent(string eventArgument)
> >
> > {
> >
> > this.Context.Trace.Write("SelectedID=" + eventArgument);
> >
> > this.SelectedID = Convert.ToInt32(eventArgument);
> >
> > }
> >
> >
> >
> > This has got to be another one of the many wier asp.net behaviors, any
> > ideas...Thanks...
> >
> >

>
>



 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      07-22-2005
See Event Below:

public void RaisePostBackEvent(string eventArgument)
{
// this writes the correct value
this.Context.Trace.Write("eventArgument=" +
this.Page.Request["__EVENTARGUMENT"]);

// this does NOT write the correct value, it is empty
this.Context.Trace.Write("eventArgument=" + eventArgument);

this.SelectedID = Convert.ToInt32(eventArgument);
}


"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:uP9E%(E-Mail Removed)...
> Did you assign the UniqueID to the name attribute of the custom Control?
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> The sun never sets on
> the Kingdom of Heaven
>
> "Mike" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I have done this many times but for some reason it's not working, the

raise
> > postback event fires but the eventArgument passed to it is empty. This

is
> > a
> > simple custom control that implements
> > IPostBackEventHandler
> >
> > and I get the href for the a tag using
> >
> > string href = this.Page.GetPostBackClientHyperlink(this,
> > tab.TabID.ToString());
> >
> > In the trace for the postback the argumts is listed but it never arrives
> > at
> >
> >
> >
> > public void RaisePostBackEvent(string eventArgument)
> >
> > {
> >
> > this.Context.Trace.Write("SelectedID=" + eventArgument);
> >
> > this.SelectedID = Convert.ToInt32(eventArgument);
> >
> > }
> >
> >
> >
> > This has got to be another one of the many wier asp.net behaviors, any
> > ideas...Thanks...
> >
> >

>
>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      07-22-2005
What does your LoadPostData method look like?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven

"Mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> See Event Below:
>
> public void RaisePostBackEvent(string eventArgument)
> {
> // this writes the correct value
> this.Context.Trace.Write("eventArgument=" +
> this.Page.Request["__EVENTARGUMENT"]);
>
> // this does NOT write the correct value, it is empty
> this.Context.Trace.Write("eventArgument=" + eventArgument);
>
> this.SelectedID = Convert.ToInt32(eventArgument);
> }
>
>
> "Kevin Spencer" <(E-Mail Removed)> wrote in message
> news:uP9E%(E-Mail Removed)...
>> Did you assign the UniqueID to the name attribute of the custom Control?
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> The sun never sets on
>> the Kingdom of Heaven
>>
>> "Mike" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> >I have done this many times but for some reason it's not working, the

> raise
>> > postback event fires but the eventArgument passed to it is empty. This

> is
>> > a
>> > simple custom control that implements
>> > IPostBackEventHandler
>> >
>> > and I get the href for the a tag using
>> >
>> > string href = this.Page.GetPostBackClientHyperlink(this,
>> > tab.TabID.ToString());
>> >
>> > In the trace for the postback the argumts is listed but it never
>> > arrives
>> > at
>> >
>> >
>> >
>> > public void RaisePostBackEvent(string eventArgument)
>> >
>> > {
>> >
>> > this.Context.Trace.Write("SelectedID=" + eventArgument);
>> >
>> > this.SelectedID = Convert.ToInt32(eventArgument);
>> >
>> > }
>> >
>> >
>> >
>> > This has got to be another one of the many wier asp.net behaviors, any
>> > ideas...Thanks...
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      07-22-2005
I did read that you may need to implement IPostBackDataHandler, would sure
like to know why?

I did try it with the same results and the code is below:

public bool LoadPostData(String postDataKey, NameValueCollection values)
{
return false;
}

public void RaisePostDataChangedEvent()
{

}



"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> What does your LoadPostData method look like?
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> The sun never sets on
> the Kingdom of Heaven
>
> "Mike" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > See Event Below:
> >
> > public void RaisePostBackEvent(string eventArgument)
> > {
> > // this writes the correct value
> > this.Context.Trace.Write("eventArgument=" +
> > this.Page.Request["__EVENTARGUMENT"]);
> >
> > // this does NOT write the correct value, it is empty
> > this.Context.Trace.Write("eventArgument=" + eventArgument);
> >
> > this.SelectedID = Convert.ToInt32(eventArgument);
> > }
> >
> >
> > "Kevin Spencer" <(E-Mail Removed)> wrote in message
> > news:uP9E%(E-Mail Removed)...
> >> Did you assign the UniqueID to the name attribute of the custom

Control?
> >>
> >> --
> >> HTH,
> >>
> >> Kevin Spencer
> >> Microsoft MVP
> >> .Net Developer
> >> The sun never sets on
> >> the Kingdom of Heaven
> >>
> >> "Mike" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> >I have done this many times but for some reason it's not working, the

> > raise
> >> > postback event fires but the eventArgument passed to it is empty.

This
> > is
> >> > a
> >> > simple custom control that implements
> >> > IPostBackEventHandler
> >> >
> >> > and I get the href for the a tag using
> >> >
> >> > string href = this.Page.GetPostBackClientHyperlink(this,
> >> > tab.TabID.ToString());
> >> >
> >> > In the trace for the postback the argumts is listed but it never
> >> > arrives
> >> > at
> >> >
> >> >
> >> >
> >> > public void RaisePostBackEvent(string eventArgument)
> >> >
> >> > {
> >> >
> >> > this.Context.Trace.Write("SelectedID=" + eventArgument);
> >> >
> >> > this.SelectedID = Convert.ToInt32(eventArgument);
> >> >
> >> > }
> >> >
> >> >
> >> >
> >> > This has got to be another one of the many wier asp.net behaviors,

any
> >> > ideas...Thanks...
> >> >
> >> >
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      07-22-2005
Hi Mike,

The LoadPostData method is the one where you get the value from the
drop-down list box. You would then loop through your data source to figure
out the selected index.

I have an article/tutorial that does just that (using VB.Net as the
language). See:

http://www.takempis.com/aspnet_anatomy3.asp

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven

"Mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I did read that you may need to implement IPostBackDataHandler, would sure
> like to know why?
>
> I did try it with the same results and the code is below:
>
> public bool LoadPostData(String postDataKey, NameValueCollection values)
> {
> return false;
> }
>
> public void RaisePostDataChangedEvent()
> {
>
> }
>
>
>
> "Kevin Spencer" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> What does your LoadPostData method look like?
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> .Net Developer
>> The sun never sets on
>> the Kingdom of Heaven
>>
>> "Mike" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > See Event Below:
>> >
>> > public void RaisePostBackEvent(string eventArgument)
>> > {
>> > // this writes the correct value
>> > this.Context.Trace.Write("eventArgument=" +
>> > this.Page.Request["__EVENTARGUMENT"]);
>> >
>> > // this does NOT write the correct value, it is empty
>> > this.Context.Trace.Write("eventArgument=" + eventArgument);
>> >
>> > this.SelectedID = Convert.ToInt32(eventArgument);
>> > }
>> >
>> >
>> > "Kevin Spencer" <(E-Mail Removed)> wrote in message
>> > news:uP9E%(E-Mail Removed)...
>> >> Did you assign the UniqueID to the name attribute of the custom

> Control?
>> >>
>> >> --
>> >> HTH,
>> >>
>> >> Kevin Spencer
>> >> Microsoft MVP
>> >> .Net Developer
>> >> The sun never sets on
>> >> the Kingdom of Heaven
>> >>
>> >> "Mike" <(E-Mail Removed)> wrote in message
>> >> news:(E-Mail Removed)...
>> >> >I have done this many times but for some reason it's not working, the
>> > raise
>> >> > postback event fires but the eventArgument passed to it is empty.

> This
>> > is
>> >> > a
>> >> > simple custom control that implements
>> >> > IPostBackEventHandler
>> >> >
>> >> > and I get the href for the a tag using
>> >> >
>> >> > string href = this.Page.GetPostBackClientHyperlink(this,
>> >> > tab.TabID.ToString());
>> >> >
>> >> > In the trace for the postback the argumts is listed but it never
>> >> > arrives
>> >> > at
>> >> >
>> >> >
>> >> >
>> >> > public void RaisePostBackEvent(string eventArgument)
>> >> >
>> >> > {
>> >> >
>> >> > this.Context.Trace.Write("SelectedID=" + eventArgument);
>> >> >
>> >> > this.SelectedID = Convert.ToInt32(eventArgument);
>> >> >
>> >> > }
>> >> >
>> >> >
>> >> >
>> >> > This has got to be another one of the many wier asp.net behaviors,

> any
>> >> > ideas...Thanks...
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >

>>
>>

>
>



 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      07-22-2005
Kevin,

This is a control that writes the html for a couple of links, no child
controls. I am simply using an anchor tag with
Page.GetPostBackClientHyperlink(this, linkID) as the href attribute when
rendering the control. linkID is just an internal ID so that the control can
tell wich link was clicked: 0,1,2,3 and so on...

The problem is that when RaisePostBackEvent is called the eventArgumet
parameter does not contain my internal ID that I pass with each link as
shown below. __EVENTARGUMENT is there just as it should be but dotnet never
hands it to my implementation of the RaisePostBackEvent. I can get it to
work if I just grab __EVENTARGUMENT from the Request object but that seems
like a rediculus hack.

public void RaisePostBackEvent(string eventArgument)
{
// this writes the correct value
this.Context.Trace.Write("eventArgument=" +
this.Page.Request["__EVENTARGUMENT"]);
// this does NOT write the correct value, it is empty
this.Context.Trace.Write("eventArgument=" + eventArgument);
}

Thanks,

Mike


"Kevin Spencer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi Mike,
>
> The LoadPostData method is the one where you get the value from the
> drop-down list box. You would then loop through your data source to figure
> out the selected index.
>
> I have an article/tutorial that does just that (using VB.Net as the
> language). See:
>
> http://www.takempis.com/aspnet_anatomy3.asp
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> .Net Developer
> The sun never sets on
> the Kingdom of Heaven
>
> "Mike" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >I did read that you may need to implement IPostBackDataHandler, would

sure
> > like to know why?
> >
> > I did try it with the same results and the code is below:
> >
> > public bool LoadPostData(String postDataKey, NameValueCollection values)
> > {
> > return false;
> > }
> >
> > public void RaisePostDataChangedEvent()
> > {
> >
> > }
> >
> >
> >
> > "Kevin Spencer" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >> What does your LoadPostData method look like?
> >>
> >> --
> >> HTH,
> >>
> >> Kevin Spencer
> >> Microsoft MVP
> >> .Net Developer
> >> The sun never sets on
> >> the Kingdom of Heaven
> >>
> >> "Mike" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> > See Event Below:
> >> >
> >> > public void RaisePostBackEvent(string eventArgument)
> >> > {
> >> > // this writes the correct value
> >> > this.Context.Trace.Write("eventArgument=" +
> >> > this.Page.Request["__EVENTARGUMENT"]);
> >> >
> >> > // this does NOT write the correct value, it is empty
> >> > this.Context.Trace.Write("eventArgument=" + eventArgument);
> >> >
> >> > this.SelectedID = Convert.ToInt32(eventArgument);
> >> > }
> >> >
> >> >
> >> > "Kevin Spencer" <(E-Mail Removed)> wrote in message
> >> > news:uP9E%(E-Mail Removed)...
> >> >> Did you assign the UniqueID to the name attribute of the custom

> > Control?
> >> >>
> >> >> --
> >> >> HTH,
> >> >>
> >> >> Kevin Spencer
> >> >> Microsoft MVP
> >> >> .Net Developer
> >> >> The sun never sets on
> >> >> the Kingdom of Heaven
> >> >>
> >> >> "Mike" <(E-Mail Removed)> wrote in message
> >> >> news:(E-Mail Removed)...
> >> >> >I have done this many times but for some reason it's not working,

the
> >> > raise
> >> >> > postback event fires but the eventArgument passed to it is empty.

> > This
> >> > is
> >> >> > a
> >> >> > simple custom control that implements
> >> >> > IPostBackEventHandler
> >> >> >
> >> >> > and I get the href for the a tag using
> >> >> >
> >> >> > string href = this.Page.GetPostBackClientHyperlink(this,
> >> >> > tab.TabID.ToString());
> >> >> >
> >> >> > In the trace for the postback the argumts is listed but it never
> >> >> > arrives
> >> >> > at
> >> >> >
> >> >> >
> >> >> >
> >> >> > public void RaisePostBackEvent(string eventArgument)
> >> >> >
> >> >> > {
> >> >> >
> >> >> > this.Context.Trace.Write("SelectedID=" + eventArgument);
> >> >> >
> >> >> > this.SelectedID = Convert.ToInt32(eventArgument);
> >> >> >
> >> >> > }
> >> >> >
> >> >> >
> >> >> >
> >> >> > This has got to be another one of the many wier asp.net behaviors,

> > any
> >> >> > ideas...Thanks...
> >> >> >
> >> >> >
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
Mike
Guest
Posts: n/a
 
      07-23-2005
PROBLEM SOLVED!!!!!

I did a project wide search for RegisterRequiresRaiseEvent and found
Page.RegisterRequiresRaiseEvent(this) was being called in another control on
the page. This completely breaks all other events on the page.

Spent two days trying to figure this out so maybe this helps someone else.

I know exactly why this caused a problem but this is just one more example
of one of those wierd things that dotnet does that drives me crazy.

Mike

"Mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I have done this many times but for some reason it's not working, the

raise
> postback event fires but the eventArgument passed to it is empty. This is

a
> simple custom control that implements
> IPostBackEventHandler
>
> and I get the href for the a tag using
>
> string href = this.Page.GetPostBackClientHyperlink(this,
> tab.TabID.ToString());
>
> In the trace for the postback the argumts is listed but it never arrives

at
>
>
>
> public void RaisePostBackEvent(string eventArgument)
>
> {
>
> this.Context.Trace.Write("SelectedID=" + eventArgument);
>
> this.SelectedID = Convert.ToInt32(eventArgument);
>
> }
>
>
>
> This has got to be another one of the many wier asp.net behaviors, any
> ideas...Thanks...
>
>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      07-25-2005
Glad you got it solved Mike, as I was away over the weekend!

--

Kevin Spencer
Microsoft MVP
..Net Developer
The sun never sets on
the Kingdom of Heaven

"Mike" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> PROBLEM SOLVED!!!!!
>
> I did a project wide search for RegisterRequiresRaiseEvent and found
> Page.RegisterRequiresRaiseEvent(this) was being called in another control
> on
> the page. This completely breaks all other events on the page.
>
> Spent two days trying to figure this out so maybe this helps someone else.
>
> I know exactly why this caused a problem but this is just one more example
> of one of those wierd things that dotnet does that drives me crazy.
>
> Mike
>
> "Mike" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> I have done this many times but for some reason it's not working, the

> raise
>> postback event fires but the eventArgument passed to it is empty. This
>> is

> a
>> simple custom control that implements
>> IPostBackEventHandler
>>
>> and I get the href for the a tag using
>>
>> string href = this.Page.GetPostBackClientHyperlink(this,
>> tab.TabID.ToString());
>>
>> In the trace for the postback the argumts is listed but it never arrives

> at
>>
>>
>>
>> public void RaisePostBackEvent(string eventArgument)
>>
>> {
>>
>> this.Context.Trace.Write("SelectedID=" + eventArgument);
>>
>> this.SelectedID = Convert.ToInt32(eventArgument);
>>
>> }
>>
>>
>>
>> This has got to be another one of the many wier asp.net behaviors, any
>> ideas...Thanks...
>>
>>

>
>



 
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
How to use a passing argument(returned argument)? ؿ Ruby 7 11-27-2008 03:53 AM
Click event does not fire - IPostBackEventHandler ? Ahmet Gunes ASP .Net Building Controls 6 08-05-2008 08:27 AM
Passing a function as an argument and using the evaluated functionas an argument User1014 Javascript 1 11-30-2006 12:13 PM
Argument-per-argument Passing Trans Ruby 3 01-26-2005 05:58 PM
Table of dynamic buttons implemeting IPostBackEventHandler =?Utf-8?B?S2xvbSBEYXJr?= ASP .Net 5 06-17-2004 06:49 AM



Advertisments