This is a migrated thread and some comments may be shown as answers.

Problem with ScriptManager.RegisterStartupScript

5 Answers 636 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Adam Hubble
Top achievements
Rank 1
Adam Hubble asked on 18 Mar 2009, 04:10 PM
Hey,

I am working on an admin interface that has a radgrid with various filter combos above it. To save the user having to scroll down the page after results load I am using this:

ScriptManager.RegisterStartupScript(Page, GetType(Page), "ScrollScript", "Sys.Application.add_load(function_scrollme() {window.scroll(0,800);});", True)

So this works in that the page scrolls to the bottom when the results load in the radgrid, however, if the user then goes back to the top of the page and does something that causes a postback e.g. they select from a combobox that populates another combo using autopostback (ajax way), then the page still scrolls to the bottom - even though I have an ajaxmanager on the page hooked up to the combo boxes.

It seems that the above code seems to fire for every subsequent postback, even controls updating in an ajax way.

Any idea how I can stop this?

Thanks,
Matt

5 Answers, 1 is accepted

Sort by
0
Adam Hubble
Top achievements
Rank 1
answered on 19 Mar 2009, 10:53 AM
It appears that the problem does not occur if I remove AJAX. So I assume the radscriptmanager must be registering the startup script for EVERY asychronous call. I just want it to register it once for a specific action then go away.
0
Accepted
SamJ
Top achievements
Rank 1
answered on 22 Mar 2009, 12:36 AM
Hi Matt,

Why don't you try the ResponseScripts property of the RadAjaxManager for your purpose?
As if it is more appropriate for your case.

SamJ
0
Adam Hubble
Top achievements
Rank 1
answered on 23 Mar 2009, 10:14 AM
Thanks a lot for replying Sam, that worked perfectly! Shame it dosn't appear to work from ajaxmanagerproxy, but that's no biggy.
0
Iana Tsolova
Telerik team
answered on 23 Mar 2009, 10:36 AM
Hello Matt,

In case you need to use the ResponseScripts property of the RadAjaxManager on a page you have RadAjaxManagerProxy, then you can try the below code:

RadAjaxManager.GetCurrent(Page).ResponseScripts.Add("alert(1)");   

Thus you can get the main ajax manager instance and use it accordingly.

Kind regards,
Iana
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Adam Hubble
Top achievements
Rank 1
answered on 23 Mar 2009, 10:58 AM
Woohoo! Thanks Iana.
Tags
Ajax
Asked by
Adam Hubble
Top achievements
Rank 1
Answers by
Adam Hubble
Top achievements
Rank 1
SamJ
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or