js調用問題
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function pushNewsDate(dataText) {
alert(dataText);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</body>
</html>
当我從其他頁面傳過來dataText這個參數時,我用button怎麼來取dataText裏面的值
------解决方案--------------------url参数吗?
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick='pushNewsDate("<%=Request.QueryString.Get('dataText')%>")'/>
------解决方案-------------------- function pushNewsDate(dataText) {
alert(dataText);
把这个改成$(#"Button1").click(function(dataText){
alert(dataText);
}
试下
------解决方案--------------------button不是用来取值的
不知道你要做什么
你想alert()传来的值?
这样就可以
<script type="text/javascript">
function pushNewsDate() {
alert("<%=Request.Params.Get("dataText").Replace("\"","\\"").Replace("\r\n","")%>");
}
</script>
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="pushNewsDate();return false;" />