Modal popup search window to replace dropdown control ASP.NET

坚强是说给别人听的谎言 提交于 2020-02-01 06:20:32

问题


I'm looking for the simplest way of popping a modal search window on top of an ASP.NET 3.5 application to look up values for a field. I've got a screen for users to add courses; users need to be able to choose an instructor by searching for instructors in a popup.

So - the popup would have a textbox and a gridview with results; clicking the "choose" button in a result would populate the instructor field on the calling form.

What's the simplest way to achieve this?


回答1:


Try using jQuery inside a UserControl with something like the tutorial from yensdesign.

The UserControl I created with this approach provided the user the option to set their preferences for the site. I found with this approach it was easier to control the interaction between the modal window and the calling window than calling a new popup browser window. One also doesn't have to worry about popup blockers getting in the way.

Is this helpful or are you looking for more detail?




回答2:


A very simple approach would be to add javascript to your page to popup a new browser window dialog, something like this:

function fnFieldSearch(searchURL)
{
    var wndSearch = window.open(searchURL,"SearchPopup","toolbar=yes,width=600,height=400,directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=no");
    wndSearch.focus();
}

On the modal search page, use javascript to send the search value back:

window.opener.document.FormName.ControlName.value = 'whatever';


来源:https://stackoverflow.com/questions/836934/modal-popup-search-window-to-replace-dropdown-control-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!