Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Page url is not changing on redirecting

I have a jquery popup login in my masterpage having contentPage url

Category.aspx

and in code behind i have written

public void Ligin_Click( object sender,EventArgs e)
{
    string Ret = objLogin.LoginValidate(
                               txtSignInEmail.Text.Trim(), 
                               txtSignInPass.Text.Trim());
     if (Ret == "1")
     {
         Response.Redirect("~/Mobile/Home.aspx?");
     }
}

but Response.Redirect was not working then i have written

Response.Redirect("~/Mobile/Home.aspx?",false);

and it is working fine. but page url is not changing it remains previous page url

Category.aspx

and link button on Home.aspx is not working, throwing exception. Invalid postback or callback argument.
Event validation is enabled using

<pages enableEventValidation="true"/> 

in configuration or

<%@Page EnableEventValidation="true" %> in a page.  

For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.
If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.


when i am typing url 'home.aspx' manualy , it is working fine.

like image 909
Durgesh Avatar asked Jan 03 '13 11:01

Durgesh


2 Answers

jQuery Mobile and asp.net web forms fundamentally don't work together. The postback model and jQuery Mobile's ajax form loading and navigation are incompatible. Move to MVC or turn off ajax.

Make sure to invoke this code before jQuery Mobile initializes. (Include it before the <script> tag that references jQuery Mobile.)

<script src="jquery.js"></script>
<script>
    $(document).bind("mobileinit", function(){
      $.mobile.ajaxEnabled = false;
    });
</script>
<script src="jquery-mobile.js"></script>

http://jquerymobile.com/demos/1.2.0/docs/api/globalconfig.html

like image 94
andleer Avatar answered Sep 21 '22 15:09

andleer


If you are stuck with trying your best to marry jQuery Mobile and ASP.NET WebForms, you can use the data-url attribute on your data-role="page" div to work around your problem of server-side redirection messing with the browser URL.

Use something equivalent to the following, in your .aspx:

<div data-role="page" data-url="<%= Request.Url.PathAndQuery %>">
...
</div>

For more details, read the section titled "Redirects and linking to directories" on this jQuery Mobile doc page.

like image 22
label17 Avatar answered Sep 18 '22 15:09

label17