Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何打开一个页面,然后调用母版页中的函数_C#_Jquery_Asp.net - Fatal编程技术网

C# 如何打开一个页面,然后调用母版页中的函数

C# 如何打开一个页面,然后调用母版页中的函数,c#,jquery,asp.net,C#,Jquery,Asp.net,下面是我的代码,我是初学者。但我希望我能解释好我的问题,提前谢谢 第2页 <asp:linkButton ID="LinkData" runat="server" > Data </asp:LinkButton> // START HERE Code Behind protected void Page_Load(object sender, EventArgs e) { LinkData.Attributes.Add('onClick', 'javascrip

下面是我的代码,我是初学者。但我希望我能解释好我的问题,提前谢谢

第2页

<asp:linkButton ID="LinkData" runat="server" > Data </asp:LinkButton>  // START HERE

Code Behind

protected void Page_Load(object sender, EventArgs e)
{  
LinkData.Attributes.Add('onClick', 'javascript:ClickData();return false;');
}
Data//从这里开始
代码隐藏
受保护的无效页面加载(对象发送方、事件参数e)
{  
Add('onClick','javascript:ClickData();returnfalse;');
}
母版页

<script>
       function ClickData() {
           window.location.href=('Page1.aspx');
          ShowData2();   // ???????????
       }
</script>


<script>

function ShowData2() {           
var Panel = document.getElementById("divData1")
if (Panel.style.display == "none" || Panel.style.display == "") {
Panel.style.display = "block";          
                document.getElementById("DataGraph").style.display = "none";
 }
 else {
 Panel.style.display = "none";
document.getElementById("DataGraph").style.display = "block";
}

}
</script>

函数ClickData(){
window.location.href=('Page1.aspx');
ShowData2();/???????????
}
函数ShowData2(){
var Panel=document.getElementById(“divData1”)
如果(Panel.style.display==“无”| | Panel.style.display==”){
Panel.style.display=“块”;
document.getElementById(“DataGraph”).style.display=“无”;
}
否则{
Panel.style.display=“无”;
document.getElementById(“DataGraph”).style.display=“block”;
}
}

window.location.href=('Page1.aspx')
是无效代码,应该是
window.location.href='Page1.aspx'
,您也可以将
window.location=…
作为快捷方式


你的函数
ShowData2
不会被调用,因为你在调用函数之前更改了url。

window.location.href=('Page1.aspx')
是无效代码,应该是
window.location.href='Page1.aspx'
,你也可以做
window.location=…
作为快捷方式。非常感谢你的回复。。。是的,我可以链接并打开第1页,但我不能在第1页内运行或调用ShowData2。对不起,我看错了您的回复,我该怎么做?调用函数然后更改url?很抱歉