Firefox not firing button event programmatically from JavaScript butIE and Safari do


B

Braden.Bowers

We have a page that contains an .ascx user control. That control has
an image button that when clicked fires a JavaScript function on the
container page. The JavaScript function finds an <asp: button > on
the container page using.

var btn = document.getElementById('<%= MyButton.ClientID %>');

<asp:Button ID="MyButton" UseSubmitBehavior="false" runat="server"
OnClick="ProcessControlAction" CssClass="Hidden" />

Then we fire that buttons onClick event.

if (btn != null ) { b.click(); }

On IE7 (Windows), IE6 (Windows), and Safari (Mac) this process runs
fine, the code behind function for MyButton fires and the web
application proceeds . Firefox however on both windows and mac gets
completely through the javascript function without throwing a
javascript error but the MyButton event never fires. Please help us
find a work-around for this problem.

Thanks in advance
Braden Bowers
 
Ad

Advertisements

B

Braden.Bowers

We have a page that contains an .ascx user control.  That control has
an image button that when clicked fires a JavaScript function on the
container page.  The JavaScript function finds an <asp: button > on
the container page using.

var btn = document.getElementById('<%= MyButton.ClientID %>');

<asp:Button ID="MyButton" UseSubmitBehavior="false" runat="server"
OnClick="ProcessControlAction" CssClass="Hidden" />

Then we fire that buttons onClick event.

if (btn != null ) { b.click(); }

On IE7 (Windows), IE6 (Windows), and Safari (Mac) this process runs
fine, the code behind function for MyButton fires and the web
application proceeds . Firefox however on both windows and mac gets
completely through the javascript function without throwing a
javascript error but the MyButton event never fires.  Please help us
find a work-around for this problem.

Thanks in advance
Braden Bowers

Hate this get frustrated and figure it out 5 minutes after posting
this question to groups.google.com
I'm assuming that since the chain of events originated from the user
control it's trying to fire an event named "ProcessControlAction" on
the .ascx which doesn't exist. You need to add PostBackUrl="<
Container page url >".

<asp:Button ID="MyButton" PostBackUrl="< Container page url >"
UseSubmitBehavior="false" runat="server"
OnClick="ProcessControlAction" CssClass="Hidden" />

Hope this saves someone else hours of research.

Braden Bowers
 

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