本文介绍了如何从Code Behind中激活Javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我在Abc.aspx文件中有一个javascript函数



ex:



Hi I have an javascript Function in Abc.aspx file

ex :

<script type="text/javascript">
     Function ShowChart(){
        //Calling Google API and 
        // Diplaying Chart 
    }    
    </script>







<pre lang="HTML">
<input id="btnPlay" type="button"  runat="server" value="Play"  önclick="initialize()"
                style="width: 80px; height: 30px;" />
<asp:Button ID="loadCh" runat="server" Text="Load Next Value" Width="120px" />





这里上面的Java脚本工作正常当我点击按钮btnPlay并显示图表

但是当我点击按钮loadCh时,会发回一个帖子,我输掉了图表值,所以我需要再次显示图表。

注意按钮LoadCh将从服务器检索数据并填入文本框和所有文件。



之后回帖我希望我的ShowChart()Java脚本被执行!



i试过以下代码后面的代码



here the Above Java Script Works Fine When i click button "btnPlay" and chart is displayed
but when i click button "loadCh" a post back occurs and i loses the chart value so i need to display the chart again.
Note button "LoadCh" will retrieve data from Server and populates in text boxes and all.

after post back i want my ShowChart() Java script to be executed!

i have tried this below Code in code behind

'System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE='JavaScript'>")
'System.Web.HttpContext.Current.Response.Write("ShowChart();")
'System.Web.HttpContext.Current.Response.Write("</SCRIPT>")
' another Code <pre>



''Page.ClientScript.RegisterClientScriptBlock(Me.GetType(),script,ShowChart();,True)

''Page .ClientScript.RegisterS tartupScript(Me.GetType(),script,ShowChart();,True)





但没有代码解雇了ShowChart函数()



任何人帮我解决方案


''Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "script", "ShowChart();", True)
''Page.ClientScript.RegisterStartupScript(Me.GetType(), "script", "ShowChart();", True)


but none of the Code Fired the function ShowChart()

Any any one help me with a solution

推荐答案



ScriptManager.RegisterStartupScript(Page, typeof(Page), "MyScriptShowChart", "ShowChart();", true);


这篇关于如何从Code Behind中激活Javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 21:19