Reputation: 35
I am starting with JQuery mobile, and I have a verty strange problem, my app is very simple, it's a page with a TextBox, a button and a Linkbutton:
<div data-role="content">
<asp:TextBox ID="TextBox_Topic" runat="server"></asp:TextBox>
<asp:Button ID="Button_add" runat="server" Text="Add" onclick="Button_add_Click" />
<asp:LinkButton ID="LinkButton_grid" runat="server" PostBackUrl="multisubsGrid.aspx" data-role="button">Continue</asp:LinkButton>
</div>
The only thing I have to do is insert text in the textbox, and when the add button is clicked add it to a Session variable (a list), and then click on the Linkbutton to go to another page. This is a very simple behaviour, and it worked fine before adding jquery mobile library. The problem is that when I insert some text and click the add button (it adds the text to the session variable) the LinkButton does not work, and I can't understand why is this happening.
this is my code behind:
protected void Button_add_Click(object sender, EventArgs e)
{
List<string> l = Session["topics"] as List<string>;
if (!l.Contains(TextBox_Topic.Text))
l.Add(TextBox_Topic.Text);
}
Hope somebody can help me. Thanks!!!
Upvotes: 0
Views: 933
Reputation: 22568
jQuery Mobile uses Ajax to load pages and the asp.net web forms postback model simply doesn't work with this default behavior. Your only option (other than moving to a different server side technology) is to turn off Ajax loading. Using the PostBackUrl attribute on a button performs a server-side redirect.
You will need to turn off Ajax loading on your <form data-ajax="false">
tag and/or button. <asp:LinkButton data-ajax="false">Continue</asp:LinkButton>
. I am not sure what behavior the PostBackUrl will introduce.
asp.net MVC is a much better choice if you want to stay with a Microsoft technology. I have also had success using straight html files for my markup and then connecting to asp.net (web form) asmx / web services if you really want to stick with web forms but this this will require heavy use of JavaScript and client-side programming.
Ajax loading is used mostly for performance and to come closer to native acting applications. If your application is intended only for intranet use or a limited audience, you can likely get away with just turning it off.
Upvotes: 3