Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > 2 controls on the same page and wrong events fire

Reply
Thread Tools

2 controls on the same page and wrong events fire

 
 
justengland@gmail.com
Guest
Posts: n/a
 
      06-01-2005
I have a button control that uses the <button> tag. I use the render
control method. I have the name attribute set to the control unique
id.

When I have 2 of these buttons on the same page, the page gets confused
as to what control fired the event. How can I make it work. Basically
it calls the last event in the list no matter which button I use to
cause the postback. I use the __dopostback to call the postback. I
have tried both calls
psudo code of course
__dopostback('controlname','');
and
__dopostback('unique id','');

I am sure that many people have had this issue so please help me.

Thanks
Justin

 
Reply With Quote
 
 
 
 
lisa@starways.net
Guest
Posts: n/a
 
      06-02-2005
Have you tried the ClientID?

Lisa


http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I have a button control that uses the <button> tag. I use the render
> control method. I have the name attribute set to the control unique
> id.
>
> When I have 2 of these buttons on the same page, the page gets confused
> as to what control fired the event. How can I make it work. Basically
> it calls the last event in the list no matter which button I use to
> cause the postback. I use the __dopostback to call the postback. I
> have tried both calls
> psudo code of course
> __dopostback('controlname','');
> and
> __dopostback('unique id','');
>
> I am sure that many people have had this issue so please help me.
>
> Thanks
> Justin


 
Reply With Quote
 
 
 
 
justengland@gmail.com
Guest
Posts: n/a
 
      06-02-2005
I have set the unique id = to
<button id='unique id' onclick=__dopostback('unique id','' >

 
Reply With Quote
 
lisa@starways.net
Guest
Posts: n/a
 
      06-02-2005
Well, you didn't say if you tried the ClientID. Have you looked in
debug mode? Are you using INamingContainer?

The reason I ask is that if you look at the HTML that gets rendered,
you'll probably see that the name and the id are different. One has an
underscore and the other has a colon. I believe it's the id that has
the underscore. The thing is, it's the name that gets posted back. So
if you're posting back the id, it may not be identifying the control
correctly.

Check it out.

Lisa


(E-Mail Removed) wrote:
> I have set the unique id = to
> <button id='unique id' onclick=__dopostback('unique id','' >


 
Reply With Quote
 
justengland@gmail.com
Guest
Posts: n/a
 
      06-02-2005
Method 1
<button ID='btOK' Name='btOK' onclick="__doPostBack('btOK','');">
<button ID='btOK1' Name='btOK1' onclick="__doPostBack('btOK1','');">
'Postback fires but no events are raised

Method 2
<button ID='btOK1' Name='_ctl0' onclick="__doPostBack('_ctl0','');">
<button ID='btOK' Name='_ctl1' onclick="__doPostBack('_ctl1','');">
'btOK click server side event is handled by both controls

method 3
<button ID='_ctl0' Name='btOK1' onclick="__doPostBack('_ctl0','');">
<button ID='_ctl1' Name='btOK' onclick="__doPostBack('_ctl1','');">
'This worked

I guess this is the opposite of IPostBackDataHandler which needs the
unique id as the name.

I am not sure what bennifit the INamingContainer is since it has 0
methods defined, but I included it anyway. Thanks for all of your
help. You made me try all combonations of the javascript, which is
what fixed the problem.

 
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
Events Events Events Please Help Chris ASP .Net Web Controls 0 08-30-2005 08:21 PM
Mutiple user controls on page to fire same validation control Martin ASP .Net 2 04-25-2005 05:20 AM
Dynamically loading ascx page and having events fire Shawn Meyer ASP .Net Building Controls 10 02-09-2004 07:55 PM
Calendar Controls don't fire events Mark Sisson ASP .Net Web Controls 2 12-03-2003 04:06 PM
Calendar Controls don't fire events Mark Sisson ASP .Net Building Controls 2 12-03-2003 04:06 PM



Advertisments