asp.net后台怎么调用前台写好的JavaScript函数 80
前台<scripttype="text/javascript">$(".btn").click(function(){is_hide();})functionis_hid...
前台
<script type="text/javascript">
$(".btn").click(function(){
is_hide();
})
function is_hide(){ $(".alert").animate({"top":"-40%"}, 300) }
function is_show(){ $(".alert").show().animate({"top":"45%"}, 300) }
</script>
后台
protected void submit_Click(object sender, EventArgs e)
{
string username = this.username.Value;
string password = this.password.Value;
if ((username == "123")&&(password == "123"))
{
//怎么调用is_show()?????
}
} 展开
<script type="text/javascript">
$(".btn").click(function(){
is_hide();
})
function is_hide(){ $(".alert").animate({"top":"-40%"}, 300) }
function is_show(){ $(".alert").show().animate({"top":"45%"}, 300) }
</script>
后台
protected void submit_Click(object sender, EventArgs e)
{
string username = this.username.Value;
string password = this.password.Value;
if ((username == "123")&&(password == "123"))
{
//怎么调用is_show()?????
}
} 展开
展开全部
不要这样写,要么都用后台,要么都用前台,推荐你用Ajax来实现,给你一个例子
function loadInfo(varCurrentIndex) {
var varEmpno = $("#<%=hidempo.ClientID %>").val();
var varSelectno = $("#<%=txtempno.ClientID %>").val();
var varstatus = $("#<%=ddl_formType.ClientID %>").find("option:selected").val();
$.ajax({
type: "Post",
url: "FormList.aspx/loadMoreData",
data: "{'strEmpno':'" + varEmpno + "','strSelectno':'" + varSelectno + "','status':'" + varstatus + "','strIndex':'" + varCurrentIndex + "'}",
timeout: 30000,
contentType: "application/json;charset=utf-8",
dataType: "json",
async: false,
beforeSend: showDiv(),
success: function (res) {
var arry = new Array()
arry = res.d.split(',');
hidDiv();
if (arry[0] != 'no') {
var htmlData = '<table style="width: 99%; margin: auto">' + arry[0] + ' </table>';
$("#dataInfo").html(htmlData);
$("#lblTotal").text(arry[1]);
if (varCurrentIndex * 5 >= parseInt(arry[1].replace(' 条', ''))) {
document.getElementById('more').style.display = 'none';
}
document.getElementById('waitingSign').style.display = 'block';
}
else {
document.getElementById('waitingSign').style.display = 'none';
}
hidDiv();
},
error: function (xmlReq, err, c) {
hidDiv();
}
});
}
仅供参考,希望对你有所帮助,谢谢,对你有用就采纳额
function loadInfo(varCurrentIndex) {
var varEmpno = $("#<%=hidempo.ClientID %>").val();
var varSelectno = $("#<%=txtempno.ClientID %>").val();
var varstatus = $("#<%=ddl_formType.ClientID %>").find("option:selected").val();
$.ajax({
type: "Post",
url: "FormList.aspx/loadMoreData",
data: "{'strEmpno':'" + varEmpno + "','strSelectno':'" + varSelectno + "','status':'" + varstatus + "','strIndex':'" + varCurrentIndex + "'}",
timeout: 30000,
contentType: "application/json;charset=utf-8",
dataType: "json",
async: false,
beforeSend: showDiv(),
success: function (res) {
var arry = new Array()
arry = res.d.split(',');
hidDiv();
if (arry[0] != 'no') {
var htmlData = '<table style="width: 99%; margin: auto">' + arry[0] + ' </table>';
$("#dataInfo").html(htmlData);
$("#lblTotal").text(arry[1]);
if (varCurrentIndex * 5 >= parseInt(arry[1].replace(' 条', ''))) {
document.getElementById('more').style.display = 'none';
}
document.getElementById('waitingSign').style.display = 'block';
}
else {
document.getElementById('waitingSign').style.display = 'none';
}
hidDiv();
},
error: function (xmlReq, err, c) {
hidDiv();
}
});
}
仅供参考,希望对你有所帮助,谢谢,对你有用就采纳额
更多追问追答
追问
没办法只用前台或后台,而且我就差这一步了,换了ajax什么都得重做
追答
那你这样试试看看行不行
submit.Attributes.Add("onClientclick", "javascript:is_show();");
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询