我正在开展一个涉及使用我网站上其他组织网站标题的项目。有一个搜索功能,如果可能的话,我需要在我的网站上工作(虽然它应该只是在org的网站上触发搜索。也就是说,如果他们输入" blah blah" 进入输入并单击Enter,然后应该打开 http://www.organization_website.org/home/search-results.aspx?Search=blah+blah )。由于我知道关于ASP.NET的没有什么,首先,有人可以告诉我,我尝试做的事情是否可行?
我试图回溯以查看我需要在我的代码中包含哪些内容才能实现此功能。当我将我的房子悬停在搜索图标上时,它会显示 javascript:__ doPostBack(' dnn $ dnnSEARCH $ cmdSearch','')。所以我搜索了函数doPostBack(...)
并找到了它:
var theForm = document.forms['Form'];
if (!theForm) {
theForm = document.Form;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
换句话说,搜索form
id
或name
等于表单,设置其中{{1}的值的input
然后提交它。由于某种原因,表单的操作被设置为页面本身....
<form method="post" action="/thispage.aspx" id="Form" enctype="multipart/form-data">
我真的不明白。无论如何,我几乎失去了。
答案 0 :(得分:0)
如果我是对的,你可以通过jquery
来完成$(document).ready(function (){
$('#searchbtn').click(function (e){
window.location = 'http://www.organization_website.org/home/search-results.aspx?Search=' + $('#searchbox').val();
//it would recirect to the url above with your search box content appended
});
});
或通过按钮单击事件内的服务器端代码 在vb代码中
response.redirect("http://www.organization_website.org/home/search-results.aspx?Search=" & searchbox.text)