开发者

ASP.NET: UpdatePanel & OnLoad Event

开发者 https://www.devze.com 2023-03-26 13:32 出处:网络
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();\">

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


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


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 ?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号