Saturday, July 24, 2010

Handling PostBack on Url Rewriting

So many of us stuck up with the problem of Postback during URL rewriting. During Postback the Url breaks up and throws error. Here is a solution to overcome this. We need to write this script in the last of the page (ie. In The Body Section.)

<script language="javascript">

function NotPostback(sNewFormAction)

{

if(document.layers) //The browser is Netscape 4

{

document.layers['Content'].document.forms[0].action = sNewFormAction;

}

else //It is some other browser that understands the DOM

{

document.forms[0].action = sNewFormAction;

}

}

NotPostback(document.URL);

script>

This calls the same Url on Postback too and thus it is solved..