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

  • Thread starter Thread starter Braden.Bowers
  • Start date Start date
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
 
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
 
Back
Top