前台js方法:
<script language="javascript" type="text/javascript">
function search(typeStr, value,judge) {
PageMethods.searchCondition(typeStr, value,judge, taskCompleted, taskFailed);
}
function taskCompleted(results, context, methodName) {
window.location.href = results;
this.f
}
function taskFailed(results, context, methodName) {
alert("发生错误异常!");
}
</script>
方法支持:
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true">
</asp:ScriptManager>
后台方法:
[WebMethod]
public static string searchCondition(string typeStr, string value, string judge)
{
if (typeStr == "quyu")
{
quyuVal = value;
if (judge == "1")
{
zquyuVal = "";
}
}
else if (typeStr == "good")
{
leixingVal = value;
}
else if (typeStr == "zhuti")
{
zhutiVal = value;
}
else if (typeStr == "fangshi")
{
fangshiVal = value;
}
else if (typeStr == "zquyu")
{
zquyuVal = value;
}
string goUrl = "www.baidu.com";
return "Pro_View.aspx?quyu=" + quyuVal +"&zquyu="+zquyuVal+ "&good=" +leixingVal + "&zhuti=" + zhutiVal + "&fangshi=" + fangshiVal + "&math=" + new Random().Next(1000, 100000);
//return "TourRoute.aspx?name=" + daysVal;
}
HTML调用js方法:
<p onclick=\"search(‘参数1‘,‘参数2‘,‘参数2‘)\" >点击执行方法</p>