开发者

Jquery Mobile: Getting a cancelled Postback that's causing a page load error

So, I've been trying to get this page working for a couple of days now, when I cli开发者_如何学编程cked the send button it would work, but if you tried to hit enter it would just do a postback to the same page. Yesterday I thought I finally got it so it would work on chrome (it has been working just fine on firefox, but breaking on chrome/safari and it is an app for the iphone). But, even though I finally got it so it would change pages, it is now displaying an error. I narrowed down the cause to a postback that is being called right before the postback I want is being sent which is then cancelled. I assume the cancelled postback is blank because the problem I was having was the page would do a blank postback.

I 'fixed' the problem by adding

javascript:if (event.keyCode == 13) __doPostBack('" & btnSearch.UniqueID & "','') 

to the onKeyPress for txtSearch. The ending html for the asp:LinkButton and asp:TextBox (which is enclosed in an asp:Panel, inside an asp:Content for a master page which is inside a form, may or may not be relevant) is

<input name="ctl00$contentMain$txtSearch" id="contentMain_txtSearch" type="text" data-type="search" onkeypress="javascript:if (event.keyCode == 13) __doPostBack('ctl00$contentMain$btnSearchByIDName','')" class="...">

<a id="contentMain_btnSearch" class="..." data-role="button" onclientclick="return false;" href="javascript:__doPostBack('ctl00$contentMain$btnSearch','')" data-theme="c"><span class="..."><span class="...">Search</span></span></a>

There is an on button click event in the code behind.

This is the header from the post, the response and everything else is empty.

Accept:text/html, */*; q=0.01
Content-Type:application/x-www-form-urlencoded
Origin:Local.Website
Referer:Local.Website/EmployeePhoneList/PhoneList.aspx
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.186 Safari/535.1
X-Requested-With:XMLHttpRequest

Anyone have any ideas how to figure out why it is doing two postbacks? Or how I could determine what is causing it? Thanks for any help.

Update: Looking further into the response, btnSearch is the origin for both the incorrect and correct postbacks. Also, things that HAVE NOT worked, AutoPostBack="false", CauseValidation="false", ViewStateMode="Disabled" and UseSubmitBehavior="false".


Have you tried disabling jQuery Mobile's Ajax navigation? Here's how I did it in an MVC project, should be similar in WebForms:

<script type="text/javascript" src="@Url.Content("~/Scripts/jquery-1.6.2.min.js")"></script>
<script type="text/javascript">
   $(document).bind("mobileinit", function() {
       $.mobile.ajaxEnabled = false;
   });
</script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.mobile-1.0b2.min.js")"></script>


While fixing an seemingly unrelated problem on another page we accidentally fixed the problem. Turns out even with ajaxEnabled = false, you sometimes need to put data-ajax="false" in the form of the masterpage to make asp.net code work correctly with JQuery mobile. Either that or rc1 fixed the problem, I don't know for sure and at this point I don't really care anymore.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜