从服务器端调用javascript函数不起作用 [英] Calling javascript function from server side not working
问题描述
这是我的JavaScript函数
< script src ="Js/jquery-1.4.1-vsdoc.js" type ="text/javascript"></script>
<脚本语言="javascript">
函数f1(){
$(#shibashish").load("TestMaster.aspx",{},函数(){});
}
</script>
这是我的源代码
Here is my javascript function
<script src="Js/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script language ="javascript" >
function f1() {
$("#shibashish").load("TestMaster.aspx", {}, function () { });
}
</script>
Here is my Sourcecode
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script src="Js/jquery-1.4.1.js" type="text/javascript"></script>
<script src="Js/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script language ="javascript" >
function f1() {
$("#shibashish").load("TestMaster.aspx", {}, function () { });
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<%--<input type ="button" value ="get page" onclick ="f1()" />--%>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button
ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</ContentTemplate>
</asp:UpdatePanel>
<br />
Hi this is static
<asp:UpdateProgress ID="UpdateProgress1" class="UpdateProgress1" runat="server">
<ProgressTemplate>
<img src="images/animations-photoshop-26.gif" style="height: 40px" />
</ProgressTemplate>
</asp:UpdateProgress>
<br />
<div id="shibashish">
hi this dynamic
</div>
</div>
</form>
</body>
</html>
这是我的活动代码
Here is my event code
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
//Page.ClientScript.RegisterStartupScript(this.GetType(), "reset", " f1();", true);
Page.ClientScript.RegisterStartupScript(Page.GetType(), "my", "f1();", true);
}
在Advance中致谢
Thanks in Advance
推荐答案
(#shibashish").load("TestMaster.aspx",{},函数(){});
}
</script>
这是我的源代码
("#shibashish").load("TestMaster.aspx", {}, function () { });
}
</script>
Here is my Sourcecode
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script src="Js/jquery-1.4.1.js" type="text/javascript"></script>
<script src="Js/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script language ="javascript" >
function f1() {
(#shibashish").load("TestMaster.aspx",{},函数(){}); } < /script > < /head > < 正文 > < 表单 =" form1" runat >服务器" > < asp:ScriptManager ID =" runat 服务器" < /asp:ScriptManager > < div > <%-<输入类型= " " 获取页面" onclick = " />-< asp:UpdatePanel ID =" runat 服务器" < ContentTemplate > < asp:Button span> =" Button1" runat =" =" Button1_Click" 文本 =" / > < /ContentTemplate > < /asp:UpdatePanel > < br > 这是静态的 < asp:UpdateProgress ID =" 类 UpdateProgress1 " runat 服务器" < ProgressTemplate > < img =" images/animations-photoshop-26.gif" 样式 =" / < /ProgressTemplate > < /asp:UpdateProgress > < br > < div =" shibashish" < /div > < /div > < /form > < /body > < /html >
("#shibashish").load("TestMaster.aspx", {}, function () { }); } </script> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <div> <%--<input type ="button" value ="get page" onclick ="f1()" />--%> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </ContentTemplate> </asp:UpdatePanel> <br /> Hi this is static <asp:UpdateProgress ID="UpdateProgress1" class="UpdateProgress1" runat="server"> <ProgressTemplate> <img src="images/animations-photoshop-26.gif" style="height: 40px" /> </ProgressTemplate> </asp:UpdateProgress> <br /> <div id="shibashish"> hi this dynamic </div> </div> </form> </body> </html>
这是我的活动代码
Here is my event code
protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
//Page.ClientScript.RegisterStartupScript(this.GetType(), "reset", " f1();", true);
Page.ClientScript.RegisterStartupScript(Page.GetType(), "my", "f1();", true);
}
在此先感谢
Thanks in Advance
以这种方式尝试:
try in this way :
string script = "<script language='javascript'>f1();</script>";
ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), script, false);
这篇关于从服务器端调用javascript函数不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!