Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I need your brains.

I need to avoid Postback while using response.Redirect since all my form are in an update panel.

When I navigate from one page to another using Response.Redirect() the whole page will get refreshed.

I need to avoid it.
Kindly give a solution

Regrds,
sajith
Posted
Updated 6-Oct-11 23:51pm
v3
Comments
Dalek Dave 7-Oct-11 5:51am    
Edited for Grammar, Spelling and Syntax.

try to put following block in web.config

XML
<system.web>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule,System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</System.web>
 
Share this answer
 
Comments
sajithnet 7-Oct-11 0:50am    
please give a valid answer
Hi,

Upto my knowledge.

response.redirect() means here you are going to display another page right?

even though you are using updatepanel the whole page will refresh because response.redirect just place your another page url into address bar this is nothing but round trip.

first response comes to browser.then second request send to server for redirected page.then second response comes to browser with your nextpage .



Two avoid whole page refreshing while moving from one page to another is achieved by using Jquery.

If you use
$("#Divid").load("yournextpage.aspx");


you can reach your requirement.

you can use updatepanel for partial page refreshing only.not to avoid refreshing while showing another page.

I hope you'll understood what I said

Here my sample code is

HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Testing Jquery methos</title>
    <script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script language ="javascript" >
      
        function openpage(pagename) {
       
                    $("#maincontent").load(pagename+".aspx #maincontent", function () {
                        // make content visible with effect   
                        
                    });

                }
              
    </script>
</head>
<body>
    <form id="form1">
    <div style=" width:100%;" align="center">
      <div style=" width:970px; background-color:Black ; height :100%;">
         <div id="headremoved" style="width:100%; height:120px; background-color:LightSkyBlue;">
           <h2>This is head content</h2>
         </div>
         <div id="menubar" style="width:100%; background-color:Chocolate ;">
           <a href="java<!-- no -->script:openpage('home')">Home</a>                        
            <a href="java<!-- no -->script:openpage('aboutus')">About US</a>                                  
             <a href="java<!-- no -->script:openpage('contactus')">Contact US</a>
         </div>
         <div id="mainremoved" style="width:100%; background-color:White;">
           This is Home content
         </div>
      </div>
    </div>
    </form>
</body>
</html>


In the above code i created page names with as it is aboutus.aspx and contactus.aspx.

All the Best.
 
Share this answer
 
v3
Comments
sajithnet 7-Oct-11 5:09am    
can u plase give the sample code
Muralikrishna8811 7-Oct-11 5:12am    
sure

I provided sample code also just check in solution
sajithnet 7-Oct-11 5:38am    
dear mulari many thanks for ur help .but ths code does not work.
what is #maincontent in the below code and please giove the code to give inside the function(// make content visible with effect ) still redirect to new page is not happening
function openpage(pagename) {

$("#maincontent").load(pagename+".aspx #maincontent", function () {
// make content visible with effect

});

}
Muralikrishna8811 7-Oct-11 5:44am    
<div id="menubar" style="width:100%; background-color:Chocolate ;">
Home
About US
Contact US
</div>
<div id="maincontent" style="width:100%; background-color:White;">
This is Home content
</div>


mainremoved is maincontent

some words are replaced by codeproject due to some reasons
Muralikrishna8811 7-Oct-11 5:48am    
remove <!-- no --> between javascript

and create pages with same name as home.aspx,contactus.aspx,aboutus.aspx
Before giving a solution I would like to explain the response.redirect.
this mean you are pysically moving from one page ot another page it wil aslo change the browser url. so it will always make a post back.

if you dont want to complete post back then i think you should use some IFrame concept
 
Share this answer
 
Comments
Toniyo Jackson 7-Oct-11 5:30am    
Correct, 5!
Dalek Dave 7-Oct-11 5:51am    
Good Answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900