ASP.NET webform error with JQuery Mobile -
ASP.NET webform error with JQuery Mobile -
here effort using jquery mobile asp.net webform. below code have used in default.aspx page. it's simple code
below finish code of aspx page.
<%@ page language="c#" autoeventwireup="true" codefile="default.aspx.cs" inherits="_default" %> <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title> login</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css" /> <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.1.min.js"></script> <script type="text/javascript" src="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js"> </script> </head> <body> <form id="form1" runat="server"> <!-- start of first page --> <div data-role="page" id="foo"> <div data-role="header"> <h1>mobile login</h1> </div><!-- /header --> <div data-role="content"> <table width="100%"> <tr width="100%"> <td width="30%" align="right" valign="middle"> <asp:literal id="lblusername" runat="server" text="user name"></asp:literal> </td> <td width="50%"> <input type="text" maxlength="20" id="username" style="width:50%;" runat="server" /> </td> </tr> <tr width="100%"> <td width="50%" align="right"> <asp:literal id="literal1" runat="server" text="password"></asp:literal> </td> <td width="50%"> <input type="text" maxlength="20" id="password" style="width:50%;" runat="server" /> </td> </tr> <tr width="100%"> <td width="50%" align="right"> </td> <td width="50%"> <table width="100%"> <tr> <td width="30%"> <asp:button id="btnlogin" runat="server" text="login" onclick="btnlogin_click" /> </td> <td width="30%"> <asp:button id="btncancel" runat="server" text="cancel" cssclass="ui-btn-active" onclick="btncancel_click" /> </td> <td width="40%"> </td> </tr> </table> </td> </tr> </table> </div><!-- /content --> <div data-role="footer"> <h4> @ right reserved. </h4> </div><!-- /footer --> </div><!-- /page --> </form> </body> </html> now on server side
protected void btnlogin_click(object sender, eventargs e) { response.redirect("home.aspx",true); } protected void btncancel_click(object sender, eventargs e) { username.value = ""; password.value = ""; } but when clicking login/cancel button nil happen other url changed from
http://localhost:2278/mobile/default.aspx
to
http://localhost:2278/mobile/default.aspx#/mobile/default.aspx
what wrong in code? can't access server side functions asp.net server controls in jquery mobile? aware can done improve in mvc that's not alternative me in case.
please help
this because .net adds type="submit" button command default. need set false , set causesvalidation false too, this:
<asp:button id="btnlogin" runat="server" text="login" onclick="btnlogin_click" causesvalidation="false" usesubmitbehavior="false" /> in fairness however, wouldn't have used server-side event navigate away on button click. can accomplish much easier way:
<a href="home.aspx" data-role="button">login</a> ..that's, of course, assuming don't have other server-side operations before navigating away.
asp.net jquery-mobile
Comments
Post a Comment