ASP.NET Update panel problem

与世无争的帅哥 提交于 2019-12-24 09:35:33

问题


I have an update panel in my page which runs a function and sends an e-mail fine but when I added in the code below it doesn't seem to add it correctly to the page

Page.ClientScript.RegisterClientScriptInclude("myscript", "/scripts/myscript.js")

All the other stuff in my Sub runs fine but it just seems to not run that bit?

Any ideas?

EDIT

Here's my code

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
    <asp:AsyncPostBackTrigger ControlID="button1" EventName="Click" />
</Triggers>
<ContentTemplate>

    <asp:TextBox ID="textbox1" runat="server"
        Text="Name" />

    <asp:LinkButton ID="button1" OnClick="submitbutton1" runat="server"
        Text="SUBMIT" />

</ContentTemplate>
</asp:UpdatePanel>

And the Sub

Sub submitbutton1(ByVal sender As Object, ByVal e As EventArgs)
    Response.write("Test")      

    Page.ClientScript.RegisterClientScriptInclude("myscript", "/scripts/myscript.js")

End Sub

回答1:


Use ScriptManager.RegisterClientScriptInclude. There is a catch, though. For each script that you want to include asynchronously, you must end it with

if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();


来源:https://stackoverflow.com/questions/6137390/asp-net-update-panel-problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!