1

I'm trying to execute some javascript code on my UpdatePanel's OnLoad event like so:

<asp:UpdatePanel ID="updDropDowns" runat="server" OnLoad="javascript:ResetButtons();">

But I keep getting "'javascript' is not a member of ASP.reasons_aspx".

I tried doing

Me.updDropDowns.Attributes.Add("OnLoad", "javascript:ResetButtons();")

But I can't reference the 'Attributes' property of an UpdatePanel in the VB code-behind.

How else can I accomplish this?

Thanks,

Jason

1
  • What about removing javascript:? Commented Aug 8, 2011 at 18:45

2 Answers 2

2

The easiest way is to register a clientscript:

ScriptManager.RegisterStartupScript(this.GetType(), "pagestart", "ResetButtons();", true)

edit: Updated per Tim's note. I referenced the wrong class

Sign up to request clarification or add additional context in comments.

2 Comments

In an Async Postback? @Jason should use the ScriptManagers's RegisterStartupScript method instead.
I'm pretty sure that 'registerstartupscript' just puts your code inside a pair of script tags. It's not doing anything like putting it in a $(document).ready() jQuery event.
0

As far as I know, their is no client OnLoad event for an updatepanel (it's rendered as a div or a span). It's only server side. And dont forget, the event will be fired each and every time the panel gets updated. Why dont you just reset your buttons server side ?

1 Comment

Problem with that is if I disable the buttons server-side, they're a bit difficult to reference later on in the client. I ended up doing something similar to David's idea. But thanks for your post!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.