Showing posts with label contain. Show all posts
Showing posts with label contain. Show all posts

Wednesday, March 28, 2012

ajax based page need to go to the top of the page....

Hi everyone ,,,

i have a page that contain update panel , that uses partial rendering ..

i need to go to the top of the page after postBack ... how do i do this ?

thnx ..


Why would you want a postback if you are using Update PanelSmile

The Update Panel and other partial rendering sections are solely meant for avoiding the page from going to the top for each and every action and retainng the scroll position.

Is there a specific reason you want the page to scroll up?


i need it because i have a gridview at the bottom of the page that i select a row from it ,

and i get an information about the row at the top of the page , if i have a lot of rows when i select a row i stay on the position of the row and the info is not display for

the user, the user need to scroll to the top of the page ..



Use this Peace of Code:
-------------------------------
<!--Add the following after the scriptmanager on your page:-->

 <script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
window.scrollTo(0,0);
}
</script>

--------------------------------

If that doesnt work for some reason, try this

Use HTML Bookmarks to achieve this without a Postback

1) Place HTML Bookmark <a name="top" >TOP</a> on Top of the Page

2) Use Response.Redirect("PageURL#top) to go to the top of the page

Read more about Bookmark on this:
http://www.freewebmasterhelp.com/tutorials/html-basics/4

Shrinand Vyas

Wednesday, March 21, 2012

Ajax and GridView Sorting or paging

Hello,

I have a main page , it's contain a call page with gridview (with features sorting and paging)

But when I click on link PAGE1, and I click on sorting, It's my page'myPageGridview.aspx' that load.

My aspx page

<head>

<title>Untitled Page</title>

<scriptlanguage=JavaScriptsrc="JavaScript/Ajax.js"></script>

</head>

<body>

<Aclass=parchemin_suite_linkonclick=javascript:show_entry('myPageGridview.aspx');href="#">Page 1</A>

<DIVid=parchemin_zonestyle="DISPLAY: none; LEFT: 102px; POSITION: absolute; TOP: 44px">

<Aonclick=javascript:hide_entry();href="#">Hidden page</A><DIVid=parchemin></DIV>

</DIV>

</body>

</html>

My Javascript page :

var ajax=false;

try

{

// All

ajax =new ActiveXObject("Msxml2.XMLHTTP");

}catch (e) {

try {

// IE

var MSXML_XMLHTTP_PROGIDS =new Array(

'MSXML2.XMLHTTP.5.0',

'MSXML2.XMLHTTP.4.0',

'MSXML2.XMLHTTP.3.0',

'MSXML2.XMLHTTP',

'Microsoft.XMLHTTP'

);

for (var i=0; i < MSXML_XMLHTTP_PROGIDS.length ; i++) {

try {

ajax =new ActiveXObject(MSXML_XMLHTTP_PROGIDS[i]);

//alert(MSXML_XMLHTTP_PROGIDS[i]);

}

catch (e)

{

ajax =false;

}

}

}

catch (E) {

ajax =false;

}

}

// Mozilla / Safari

if (!ajax &&typeof(XMLHttpRequest)!='undefined') {

ajax =new XMLHttpRequest();

}

function getMyHTML(serverPage, objID) {

ajax.open("GET", serverPage);

ajax.onreadystatechange =function() {

//alert("Status : " + ajax.status);

if (ajax.readyState == 4 && ajax.status == 200) {

document.getElementById(objID).innerHTML = ajax.responseText;

document.getElementById('parchemin_zone').style.display='';

}

}

ajax.send(null);

}

function show_entry(entry_id)

{

getMyHTML(entry_id,'parchemin');

}

function hide_entry()

{

document.getElementById('parchemin_zone').style.display='none';

}

function view_entry()

{

document.getElementById('parchemin_zone').style.display='inline';

}

function ismaxlength(obj){

var mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) :""

if (obj.getAttribute && obj.value.length > mlength)

obj.value = obj.value.substring(0, mlength)

}

nobody has idea ?

when I use an Autopostback, I have this error.

For exemple, I have a main page width 3 page include in Ajax.

when I use autopostback, my page reload width only my table.


Instead of using Ajax I would recommend that you use Atlas. What's the difference? Well Atlas is based on Ajax, at least the idea of Ajax anyway, but it does all the hard work for you. If you download the December release of Atlas (http://www.asp.net/default.aspx?tabindex=7&tabid=47) and visit this blog (http://www.nikhilk.net/AtlasM1.aspx) you will see how easy it is to use. It will virtually eliminate any XML or JavaScript that you have to write. But to answer you question directly. I have no idea what could be wrong with your code. I think that your question would be best served on an Ajax specific forum.

Good luck.