ASP.Net Button w/onclick script misbehaves when in user control

V

Vince

I'm using VS 2003 and I have a button in a page where I've used
"btnViewData.Attributes.Add ("onclick", "javascript:return doPostBack
(\"" + btnViewData.ClientID + "\");");"
to have it execute some javascript before posting back. It works fine
in the page and executes my javascript, and then executes its
server-side event. I'm trying to reuse most of the page's controls
across several pages, but when I move the button from the page into a
user control, the button correctly fires my javascript function, but no
longer fires its server-side Click event, even though I see that the
page's Request.Params[0] correctly points to my control.

In trying to find workarounds, I tried dynamically modifying the
button's onclick event in the page's onLoad event, and then it does fire
the server-side event, however it bypasses my javascript function.

Any ideas why this is happening and how I can fix it?

Thanks in advance,
Vince
 
V

Vince

I should mention that in my client-side doPostBack function I disable
all controls on the page and then manually call the __doPostBack
function, passing the name of the submitting control. I have to do that
because if I disable a button and return true, the framework won't
submit a disabled button. Anyway, it appears that the __doPostBack only
works for controls that are on the page, but not for controls that are
within user controls. Does that make sense?

Thanks,
Vince
 

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

Top