Hi ,
I have search textbox and button in master page. If I click on search button it will show ajax modal popup with user contorl and load all the results.its is working fine without any issue.
The issue when I press enter in textbox it is opening modalpopup but wrong event is firing instead of search event.I have set panel with default button as search. I dont know still it is firing some pagination event.
This is my modal popup user control code
<asp:Panel ID="pnlDefault" runat=server DefaultButton="btnHiddenSearch">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" Visible="true">
<ContentTemplate>
<script type="text/javascript">
//triggers search popup
function fireSearchPopupFromEnter(imageButtonClientId)
{
//if enter has been pressed
if(window.event && window.event.keyCode == 13)
{
var imageButton = document.getElementById(imageButtonClientId);
imageButton.focus();
imageButton.click();
return false;
}
return true;
}
var baseId;
var baseKey;
var baseValue;
function rememberClickValue(id, value)
{
baseId = id;
baseValue = value;
}
function rememberClickKeyValue(id, key, value)
{
baseId = id;
baseKey = key;
baseValue = value;
}
function AssignValues(idObject, idValue, nameObject, nameValue, additionalIDs, additionalValues)
{
if(idObject.trim() != "")
{
var id = document.getElementById(idObject);
id.value = idValue;
}
if(nameObject.trim() != "")
{
var name = document.getElementById(nameObject);
name.value = nameValue;
}
if(additionalIDs != null && additionalIDs.trim() != "" && additionalValues != null && additionalValues.trim() != "")
{
var additionalIDArr = additionalIDs.split("$-#!$");
var additionalValueArr = additionalValues.split("$-#!$");
var parentControl;
for(i = 1; i<additionalIDArr.length; i++)
{
if(additionalIDArr[i].trim() != "")
{
parentControl = document.getElementById(additionalIDArr[i]);
parentControl.value = additionalValueArr[i];
}
}
}
}
//BELOW ARE THE SCRIPTS NECESSARY FOR RETAINING SEARCH RESULTS
//Make sure we run "<%=ClientID + "_modalSetup"%>" function when we first load the page
Sys.Application.add_load(<%=ClientID + "_modalSetup"%>);
//Add "<%=ClientID + "_PopupFired"%>" function to the shown event of the modal popup extender
function <%=ClientID + "_modalSetup()"%>
{
var modalPopup = $find("<%=ClientID + "_PopupBehaviour"%>");
modalPopup.add_shown(<%=ClientID + "_PopupFired"%>);
}
//When we first load the page, popup is not launched yet
var <%=ClientID + "_IsPopupFiredOnce"%> = '<%=(Session[ClientID + "_stringCriteria"] == null).ToString().ToUpper()%>';
//Makes an AJAX search request into the modal popup
function <%=ClientID + "_PopupFired()"%>
{
//If this is a IncomingWordSearch from the left side then we must click the search button
if(('<%=IncomingWordSearch.ToString().ToUpper()%>' == 'TRUE'))
{
//var search = document.getElementById("<%=ClientID %>" + "_btnSearch");
//search.click();
var searchHidden = document.getElementById("<%=ClientID %>" + "_btnHiddenSearch");
searchHidden.focus();
alert('hi');
//searchHidden.style.display = "none";
searchHidden.click();
return;
}
//Connect hidden button and make it invisible; it is not supposed to be visible but we didn't make it invisible
//at the client side since we won't be able to click it then
var searchHidden = document.getElementById("<%=ClientID %>" + "_btnHiddenSearch");
searchHidden.style.display = "none";
//Only try to retain search results if results not already at the client (<%=ClientID + "_IsPopupFiredOnce"%>) and we are supposed
//to retain the search result (<%=RetainSearchResult.ToString().ToUpper()%>)
if((<%=ClientID + "_IsPopupFiredOnce"%> == 'FALSE') && ('<%=RetainSearchResult.ToString().ToUpper()%>' == 'TRUE'))
{
//Click the hidden button so when first time we show the popup, we make sure we get the result into it (if we are supposed to retain the search result)
searchHidden.click();
//Mark the variable so we won't click hidden button since we have the result at the client (popup launched once at the client)
<%=ClientID + "_IsPopupFiredOnce"%> = "true";
}
}
</script>
<div id="pcontent">
<asp:UpdatePanel ID="upLetters" runat="server" UpdateMode="Conditional" Visible="true" RenderMode="Inline" >
<ContentTemplate>
<ul class="searchbar">
<li class="firstitem"><asp:ImageButton id="btn_" runat="server" CommandArgument="_" OnClick="Letter_Click" ImageUrl="~/images/popup/hash.gif" AlternateText="Search #" Width="19" Height="18" TabIndex="-1" CausesValidation="false" /></li>
</ContentTemplate>
</asp:UpdatePanel>
</div> <!--pcontent-->
<div class="searchtxtbox" runat=server id="searchtxtbox">
<asp:label id="lblCriteriaCaption" AssociatedControlID="txtSearchCriteria" runat="server">Missing Title</asp:label>
<asp:TextBox ID="txtSearchCriteria" runat="server" TabIndex="1"></asp:TextBox>
</div>
<div class="searchradio" runat="server" id="boxSearchRadio">
<input type="radio" name="scope" id="searchOptionPhrase" value="phrase" runat="server" checked="true" /> <asp:label ID="Label1" runat="server" AssociatedControlID="searchOptionPhrase">Phrase Search</asp:label>
<input type="radio" name="scope" id="searchOptionWord" value="word" runat="server"/> <asp:label ID="Label2" runat="server" AssociatedControlID="searchOptionWord">Word Search</asp:label>
</div>
<div class="searchbtn">
<asp:ImageButton id="btnSearch" OnClick="btnSearch_Click" runat="server" ImageUrl="~/images/search_btn.gif" AlternateText="Search" CausesValidation="false"/>
<asp:ImageButton id="btnHiddenSearch" OnClick="btnHiddenSearch_Click" runat="server" ImageUrl="~/images/search_btn.gif" AlternateText="Search hidden" CausesValidation="false" style="display:none"/>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
Please suggest me to resolve this issue.
Thanks
Bhavani