I'm developing a web application in asp(mobile).
When using the iPhone browser for entering some search text in the search text box (<mobile:TextBox ID="txtSearchData" Runat="server" BreakAfter=False></mobile:TextBox>
) , the iPhone launches the search keypad and when I click the search button using the iPhone keypad it refreshes the full page, but clicking the search button below the textbox it is working fine.
Here's my code so far:
<body> <mobile:Form ID="frmSearch" Runat="server" Font-Name="NotSet" Font-Size="Small"> <mobile:DeviceSpecific ID="dsSearch" Runat="server"> <Choice Filter="isHTML32"> <ScriptTemplate> <link href="StyleSheets/Common.css" rel="stylesheet" type="text/css"></link> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta id="Meta1" name="viewport" content="width=device-width; initial-scale=1.0;" /> </ScriptTemplate> <HeaderTemplate> <table cellspacing="2" width="100%"> <tr> <td width="100%"> <uc1:Header ID="ucHeader" runat="server" /> </td> </tr> </table> <table> <tr> <td colspan="2"></td> </tr> <tr> <td align="right"> Find : </td> <td> <mobile:DeviceSpecific> <Choice="isHTML32"> <ContentTemplate> <asp:DropDownList ID="lstGroups" runat="server" OnSelectedIndexChanged="LstGroups_SelectedIndexChanged" AutoPostBack="true"> </asp:DropDownList> </ContentTemplate> </Choice> </mobile:DeviceSpecific> </td> </tr> <tr> <td align="right"> Search by:</td> <td> <mobile:SelectionList ID="lstSearchPreferences" Runat="server" BreakAfter=False> <Item Selected=True Text="select" /> </mobile:SelectionList> </td> </tr> <tr> <td> </td> <td> <mobile:SelectionList ID="lstSearchOptions" Runat="server" BreakAfter=False> </mobile:SelectionList> </td> </tr> <tr> <td> </td> <td> <mobile:TextBox ID="txtSearchData" Runat="server" BreakAfter=False> </mobile:TextBox> </td> </tr> <tr id="trContractorFilter" runat="server" visible="False"> <td align="right"> <mobile:Label id="lblContractorFilter" BreakAfter=False Runat="server" Visible="True" > Results: </mobile:Label> </td> <td> <mobile:SelectionList ID="lstContractorFilter" Runat="server" BreakAfter="True" Visible ="True" > <Item Selected="True" Text="Active Permits" /> <Item Text="All Permits" /> </mobile:SelectionList> (your permits only) </td> </tr> <tr> <td colspan="2"></td> </tr> <tr> <td colspan="2"></td> </tr> <tr> <td colspan="2"></td> </tr> <tr> <td colspan="2" align="center"> <mobile:DeviceSpecific> <Choice="isHTML32"> <ContentTemplate> <asp:Button ID="btnSearch" runat="server" Text="Search" UseSubmitBehavior=true OnClick="BtnSearch_Click"/> </ContentTemplate> </Choice> </mobile:DeviceSpecific> </td> </tr> <tr> <td colspan="2" align="center"> <mobile:Label ID="lblError" Runat="server" Font-Bold="True" ForeColor=Red Visible="false" BreakAfter=False></mobile:Label> </td> </tr> </table> </HeaderTemplate> </Choice> </mobile:DeviceSpecific> </mobile:Form> </body>
You can do a Control-F search on an iPhone's browser by using the "On This Page," "Find in Page," or Share features. Control-F is a computer shortcut that locates specific words or phrases on a webpage or document. You can search for specific words or phrases in Safari, Google Chrome, and Messages.
Swipe down from the middle of the Home screen. Tap the Search field, then enter what you're looking for. As you type, Search updates results in real time. To see more results, tap Show More or search directly in an app by tapping Search in App.
In conjunction with this question and its answer using jQuery, you can write this same code in your page and do the client processing before firing the submit.
Additionally, you can use $.ajax()
library functions to submit the form asynchronously(within the above discussed code block and not firing the form.submit()
at all), which will eliminate any page refresh (no matter from where the form submit event is fired.)
<form id="hello-world" action="sayhello"> <input type="submit" value="Hello!"> </form>
You can attach an event handler like this:
$('#hello-world').submit(function(ev) { ev.preventDefault(); // to stop the form from submitting /* Validations go here */ //this.submit(); // If all the validations succeeded $.ajax({ url:'your_form_target', data:formData, success:function(data,textStatus, jqXHR){ } }); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With