本文介绍了如何使用javascript执行codebehind函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好, 我想在javascript中执行我的代码隐藏在同一个aspx页面上。 我的javascript ..Hello everyone,I want to execute my code behind function in javascript which is on the same aspx page.my javascript..<script type="text/javascript"> var xmlhttp; function loadXMLDoc(url, cfunc) { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } if (xmlhttp != null) { xmlhttp.onreadystatechange = cfunc; xmlhttp.open("GET", url, true); // xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8"); xmlhttp.send(); } else { alert("Page can not process"); } } function insertSealDetails() { // var username = $('#username').val(); // var password = $('#password').val(); var sealname = document.getElementById('<%= txtSealName.ClientID %>').value; var sealdesc = document.getElementById('<%= txtSealDescription.ClientID %>').value; var url = ""; if ((sealname == null || sealname == '')) { alert("Please enter Sealname."); return; } url = "AjaxFunctions.aspx?sealname=" + sealname + "&sealdesc=" + sealdesc + "&Action=insertsealdetails"; loadXMLDoc(url, function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { var t = xmlhttp.responseText; t = t.replace(/^(.*\n)*.*<html/i, "<html"); t = t.replace(/<\/html>(.*\n)*.*$/i, "</html>"); var parser = new DOMParser(); var dom = parser.parseFromString(t, "text/xml"); // x = dom.getElementById("responseText").firstChild; //alert(x); var response = dom.childNodes[0].getAttribute("name"); if (response == "1") { <%FillGDVSeal(); %>; } else if (response == "0") { //alert('Invalid login !!'); } } }); } </script>my code behind method.. protected void FillGDVSeal() { lbMessage.Text = "Inserted"; } javascript和代码隐藏文件是.aspx页面相同.. 我无法获得任何输出...请帮助我... 谢谢&问候, krunal panchalboth javascript and code behind file are of same .aspx page..I am not able to get any kind of output ...please help me...thanks & regards,krunal panchal推荐答案 javascript和代码隐藏文件是.aspx页面相同.. 我无法获得任何输出...请帮助我... 谢谢&问候, krunal panchalboth javascript and code behind file are of same .aspx page..I am not able to get any kind of output ...please help me...thanks & regards,krunal panchal 这篇关于如何使用javascript执行codebehind函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-15 19:10
查看更多