开发者

ASP.NET Update panel problem

I have an update panel in my page which runs a function and sends an e-mail fine but when开发者_如何学JAVA 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


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();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜